pyarmor 8.2.7__zip → 8.2.9__zip

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.
Files changed (119) hide show
  1. {pyarmor-8.2.7 → pyarmor-8.2.9}/PKG-INFO +1 -1
  2. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/__init__.py +1 -1
  3. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/__main__.py +3 -4
  4. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/bootstrap.py +1 -1
  5. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/default.cfg +3 -3
  6. pyarmor-8.2.9/pyarmor/cli/docker.py +148 -0
  7. pyarmor-8.2.9/pyarmor/cli/group.py +101 -0
  8. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/register.py +28 -5
  9. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/repack.py +2 -1
  10. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/config.py +1 -1
  11. pyarmor-8.2.9/pyarmor/pyarmor-deprecated.py +843 -0
  12. pyarmor-8.2.9/pyarmor/pyimcore.py +65 -0
  13. {pyarmor-8.2.7 → pyarmor-8.2.9}/pyarmor.egg-info/PKG-INFO +1 -1
  14. pyarmor-8.2.9/pyarmor.egg-info/SOURCES.txt +115 -0
  15. {pyarmor-8.2.7 → pyarmor-8.2.9}/pyarmor.egg-info/entry_points.txt +1 -0
  16. pyarmor-8.2.9/pyarmor.egg-info/requires.txt +1 -0
  17. {pyarmor-8.2.7 → pyarmor-8.2.9}/setup.py +3 -2
  18. pyarmor-8.2.7/pyarmor.egg-info/SOURCES.txt +0 -111
  19. pyarmor-8.2.7/pyarmor.egg-info/requires.txt +0 -1
  20. {pyarmor-8.2.7 → pyarmor-8.2.9}/MANIFEST.in +0 -0
  21. {pyarmor-8.2.7 → pyarmor-8.2.9}/README.md +0 -0
  22. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/README.rst +0 -0
  23. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/__init__.py +0 -0
  24. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/benchmark.py +0 -0
  25. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/build_meta.py +0 -0
  26. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/config.py +0 -0
  27. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/context.py +0 -0
  28. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/generate.py +0 -0
  29. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/merge.py +0 -0
  30. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/mixer.py +0 -0
  31. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/plugin.py +0 -0
  32. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/public_capsule.zip +0 -0
  33. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/resource.py +0 -0
  34. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cli/shell.py +0 -0
  35. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/cobuilder.py +0 -0
  36. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/README-ZH.md +0 -0
  37. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/README.md +0 -0
  38. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/build-for-exe.bat +0 -0
  39. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/build-for-freeze.bat +0 -0
  40. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/build-with-project.bat +0 -0
  41. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/build-with-project.sh +0 -0
  42. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/cx_Freeze/hello.py +0 -0
  43. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/cx_Freeze/queens.py +0 -0
  44. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/cx_Freeze/setup.py +0 -0
  45. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/helloworld/foo.py +0 -0
  46. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-app.bat +0 -0
  47. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-app.sh +0 -0
  48. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-pkg.bat +0 -0
  49. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-pkg.sh +0 -0
  50. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pack-obfuscated-scripts.bat +0 -0
  51. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pack-obfuscated-scripts.sh +0 -0
  52. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/py2exe/hello.py +0 -0
  53. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/py2exe/queens.py +0 -0
  54. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/py2exe/setup.py +0 -0
  55. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Arithmetic.py +0 -0
  56. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Calls.py +0 -0
  57. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/CommandLine.py +0 -0
  58. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Constructs.py +0 -0
  59. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Dict.py +0 -0
  60. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Exceptions.py +0 -0
  61. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Imports.py +0 -0
  62. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Instances.py +0 -0
  63. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Lists.py +0 -0
  64. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Lookups.py +0 -0
  65. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/NewInstances.py +0 -0
  66. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Numbers.py +0 -0
  67. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Setup.py +0 -0
  68. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Strings.py +0 -0
  69. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Tuples.py +0 -0
  70. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/With.py +0 -0
  71. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/clockres.py +0 -0
  72. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/package/__init__.py +0 -0
  73. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/package/submodule.py +0 -0
  74. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/pybench.py +0 -0
  75. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/pybench/systimes.py +0 -0
  76. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/simple/queens.py +0 -0
  77. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/testmod/hello.py +0 -0
  78. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/testmod/queens.py +0 -0
  79. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/testpkg/main.py +0 -0
  80. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/testpkg/mypkg/__init__.py +0 -0
  81. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/examples/testpkg/mypkg/foo.py +0 -0
  82. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/__init__.py +0 -0
  83. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/build_data_module.py +0 -0
  84. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/buildext.py +0 -0
  85. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/get_bind_key.py +0 -0
  86. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/get_license_info.py +0 -0
  87. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/get_platform_name.py +0 -0
  88. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/merge.py +0 -0
  89. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/repack.py +0 -0
  90. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/helper/superuntime.py +0 -0
  91. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/license.tri +0 -0
  92. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/packer.py +0 -0
  93. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/platforms/darwin/x86_64/_pytransform.dylib +0 -0
  94. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/platforms/linux/x86/_pytransform.so +0 -0
  95. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/platforms/linux/x86_64/_pytransform.so +0 -0
  96. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/platforms/windows/x86/_pytransform.dll +0 -0
  97. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/platforms/windows/x86_64/_pytransform.dll +0 -0
  98. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/plugins/README.md +0 -0
  99. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/plugins/check_ntp_time.py +0 -0
  100. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/polyfills/__init__.py +0 -0
  101. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/polyfills/argparse.py +0 -0
  102. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/product.key +0 -0
  103. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/project.py +0 -0
  104. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/protect_code.pt +0 -0
  105. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/protect_code2.pt +0 -0
  106. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/public.key +0 -0
  107. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/public_capsule.zip +0 -0
  108. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/pyarmor-webui.py +0 -0
  109. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/pyarmor.py +0 -0
  110. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/pyshield.key +0 -0
  111. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/pyshield.lic +0 -0
  112. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/pytransform.py +0 -0
  113. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/reform.py +0 -0
  114. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/register.py +0 -0
  115. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/sppmode.py +0 -0
  116. {pyarmor-8.2.7/src → pyarmor-8.2.9/pyarmor}/utils.py +0 -0
  117. {pyarmor-8.2.7 → pyarmor-8.2.9}/pyarmor.egg-info/dependency_links.txt +0 -0
  118. {pyarmor-8.2.7 → pyarmor-8.2.9}/pyarmor.egg-info/top_level.txt +0 -0
  119. {pyarmor-8.2.7 → pyarmor-8.2.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: pyarmor
3
- Version: 8.2.7
3
+ Version: 8.2.9
4
4
  Summary: A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
5
5
  Home-page: https://github.com/dashingsoft/pyarmor
6
6
  Author: Jondy Zhao
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
 
3
- __VERSION__ = '8.2.7'
3
+ __VERSION__ = '8.2.9'
4
4
 
5
5
  logger = logging.getLogger('cli')
6
6
 
@@ -405,7 +405,7 @@ https://pyarmor.readthedocs.io/en/stable/reference/man.html#pyarmor-gen
405
405
  )
406
406
  group.add_argument(
407
407
  '--exclude', dest='excludes', metavar='PATTERN', action='append',
408
- help=argparse.SUPPRESS
408
+ help='Exclude scripts and paths'
409
409
  )
410
410
 
411
411
  group.add_argument(
@@ -490,7 +490,7 @@ https://pyarmor.readthedocs.io/en/stable/reference/man.html#pyarmor-gen
490
490
  help='set expired date'
491
491
  )
492
492
  group.add_argument(
493
- '--period', type=int, metavar='N', dest='period',
493
+ '--period', metavar='N', dest='period',
494
494
  help='check runtime key periodically'
495
495
  )
496
496
  group.add_argument(
@@ -503,8 +503,7 @@ https://pyarmor.readthedocs.io/en/stable/reference/man.html#pyarmor-gen
503
503
  )
504
504
 
505
505
  cparser.add_argument(
506
- 'inputs', metavar='ARG', nargs='+',
507
- help='script, package or keyword "key", "runtime"'
506
+ 'inputs', metavar='ARG', nargs='+', help='scripts or packages'
508
507
  )
509
508
 
510
509
  cparser.set_defaults(func=cmd_gen)
@@ -35,7 +35,7 @@ def check_prebuilt_runtime_library(platnames, extra=None, rtver=''):
35
35
  'install it'.format('pyarmor.cli.core'))
36
36
 
37
37
  instcmd = [sys.executable, '-m', 'pip', 'install',
38
- '--disable-pip-version-check']
38
+ '--disable-pip-version-check']
39
39
 
40
40
  # Before Pyarmor 8.3, prefer to "pyarmor.cli.runtime"
41
41
  # It could be disabled by
@@ -3,10 +3,10 @@
3
3
  ;; Pyarmor version
4
4
  major = 8
5
5
  minor = 2
6
- patch = 7
6
+ patch = 9
7
7
 
8
8
  ;; Core version
9
- cli.core = 3.2.6
9
+ cli.core = 3.2.9
10
10
 
11
11
  ;; Deprecated since Pyarmor 8.2.5
12
12
  ; cli.runtime = 3.2.5
@@ -27,7 +27,7 @@ trace_logfile = .pyarmor/pyarmor.trace.log
27
27
  [finder]
28
28
  recursive = 0
29
29
  ;; includes =
30
- excludes = *__pycache__
30
+ excludes = */__pycache__
31
31
  pyexts = .py .pyw
32
32
 
33
33
  ;; Data files need to copy to output path
@@ -0,0 +1,148 @@
1
+ import argparse
2
+ import logging
3
+ import os
4
+ import socketserver
5
+ import struct
6
+ import sys
7
+
8
+ from .context import Context
9
+ from .generate import Builder, Pytransform3
10
+ from .register import Register
11
+
12
+
13
+ CONFIG = {
14
+ 'port': 29092,
15
+ 'home': os.path.expanduser(os.path.join('~', '.pyarmor', 'docker')),
16
+ 'machid': None,
17
+ 'ctx': None,
18
+ }
19
+
20
+
21
+ class DockerAuthHandler(socketserver.BaseRequestHandler):
22
+
23
+ def handle(self):
24
+ data = self.request.recv(64)
25
+ logging.info('receive request from %s', self.client_address)
26
+ try:
27
+ logging.debug('request data (%d): %s', len(data), data)
28
+ response = self.process(data)
29
+ logging.info('send auth result to %s', self.client_address)
30
+ logging.debug('response data (%d): %s', len(response), response)
31
+ except Exception as e:
32
+ logging.error('%s', str(e))
33
+ msg = 'verification failed, please check host console'.encode()
34
+ msg += b'\00'
35
+ self.request.send(struct.pack('!HH', 1, len(msg)) + msg)
36
+
37
+ def process(self, packet):
38
+ if packet[:4] == b'PADH':
39
+ response = CONFIG['machid']
40
+ self.request.send(response)
41
+ else:
42
+ userdata = self.parse_packet(packet)
43
+ keydata = self.generate_runtime_key(userdata.decode('utf-8'))
44
+ response = struct.pack('!HH', 0, len(keydata)) + keydata
45
+ self.request.send(response)
46
+ return response
47
+
48
+ def parse_packet(self, packet):
49
+ if len(packet) == 32 and packet[:4] == b'PADK':
50
+ return packet[12:]
51
+ raise RuntimeError('invalid auth request')
52
+
53
+ def generate_runtime_key(self, userdata):
54
+ ctx = CONFIG['ctx']
55
+ ctx.cmd_options['user_data'] = userdata
56
+ return Builder(ctx).generate_runtime_key()
57
+
58
+
59
+ def register_pyarmor(ctx, regfile):
60
+ reg = Register(ctx)
61
+ logging.info('register "%s"', regfile)
62
+ reg.register_regfile(regfile)
63
+ if reg.license_info['features'] < 15:
64
+ raise RuntimeError('this feature is only for group license')
65
+ Pytransform3._update_token(ctx)
66
+
67
+
68
+ def main_entry():
69
+ parser = argparse.ArgumentParser()
70
+ parser.add_argument('--debug', action='store_true',
71
+ help='Enable debug mode')
72
+ parser.add_argument('-p', '--port', type=int, default=CONFIG['port'],
73
+ help=argparse.SUPPRESS)
74
+ parser.add_argument('-s', '--sock', default='/var/run/docker.sock',
75
+ help=argparse.SUPPRESS)
76
+ parser.add_argument('--home', help=argparse.SUPPRESS)
77
+ parser.add_argument('regfile', nargs=1,
78
+ help='group device registration file for this machine')
79
+ args = parser.parse_args(sys.argv[1:])
80
+
81
+ if args.debug:
82
+ logging.getLogger().setLevel(logging.DEBUG)
83
+
84
+ if args.home:
85
+ CONFIG['home'] = os.path.expandvars(os.path.expanduser(args.home))
86
+ home = CONFIG['home']
87
+ logging.info('work path: %s', home)
88
+
89
+ ctx = Context(home=home)
90
+ register_pyarmor(ctx, args.regfile[0])
91
+ CONFIG['ctx'] = ctx
92
+
93
+ CONFIG['machid'] = Pytransform3.get_hd_info(11)
94
+ logging.debug('machine id: %s', CONFIG['machid'])
95
+
96
+ host, port = '0.0.0.0', args.port
97
+ with socketserver.TCPServer((host, port), DockerAuthHandler) as server:
98
+ logging.info('listen container auth request on %s:%s', host, args.port)
99
+ server.serve_forever()
100
+
101
+
102
+ def main():
103
+ logging.basicConfig(
104
+ level=logging.INFO,
105
+ format='%(asctime)s: %(message)s',
106
+ )
107
+ main_entry()
108
+
109
+
110
+ #
111
+ # Deprecrated functions
112
+ #
113
+ def get_docker_gateway(client):
114
+ filters = {
115
+ 'driver': 'bridge',
116
+ 'type': 'builtin'
117
+ }
118
+ networks = client.networks.list(filters=filters)
119
+ return networks[0].attrs['IPAM']['Config'][0]['Gateway']
120
+
121
+
122
+ def get_container(client, ipaddr):
123
+ filters = {
124
+ 'driver': 'bridge',
125
+ 'type': 'builtin'
126
+ }
127
+ networks = client.networks.list(filters=filters, greedy=True)
128
+ containers = networks[0].attrs.get('Containers')
129
+ if containers:
130
+ marker = ipaddr + '/'
131
+ for dockid, netattr in containers.items():
132
+ if netattr.get('IPv4Address').startswith(marker):
133
+ return client.containers.get(dockid)
134
+ raise RuntimeError('no found countainer with IPv4 %s' % ipaddr)
135
+
136
+
137
+ def copy_file_into_docker(containerid, filename):
138
+ from subprocess import check_call
139
+ check_call(['docker', 'cp', filename, '%s:/' % containerid])
140
+
141
+
142
+ def get_container_info(client, shortid):
143
+ container = client.container.get(shortid)
144
+ return container.attrs
145
+
146
+
147
+ if __name__ == '__main__':
148
+ main()
@@ -0,0 +1,101 @@
1
+ import argparse
2
+ import logging
3
+ import os
4
+ import socketserver
5
+ import struct
6
+ import sys
7
+
8
+ from .context import Context
9
+ from .generate import Builder, Pytransform3
10
+ from .register import Register
11
+
12
+ PORT = 29092
13
+
14
+
15
+ class DockerAuthHandler(socketserver.BaseRequestHandler):
16
+
17
+ WORKPATH = os.path.expanduser(os.path.join('~', '.pyarmor', 'docker'))
18
+ CTX = None
19
+
20
+ def handle(self):
21
+ data = self.request.recv(64)
22
+ logging.info('receive request from %s', self.client_address)
23
+ try:
24
+ logging.debug('data (%d): %s', len(data), data)
25
+ self.process(data)
26
+ logging.info('send auth result to %s', self.client_address)
27
+ except Exception as e:
28
+ logging.error('%s', str(e))
29
+ msg = 'failed to verify docker, please check host console'.encode()
30
+ msg += b'\00'
31
+ self.request.send(struct.pack('!HH', 1, len(msg)) + msg)
32
+
33
+ def process(self, packet):
34
+ if packet[:4] == b'PADH':
35
+ self.request.send(self.MACHID)
36
+ else:
37
+ userdata = self.parse_packet(packet)
38
+ keydata = self.generate_runtime_key(userdata.decode('utf-8'))
39
+ self.request.send(struct.pack('!HH', 0, len(keydata)) + keydata)
40
+
41
+ def parse_packet(self, packet):
42
+ if len(packet) == 32 and packet[:4] == b'PADK':
43
+ return packet[12:]
44
+ raise RuntimeError('invalid auth request')
45
+
46
+ def generate_runtime_key(self, userdata):
47
+ ctx = self.CTX
48
+ ctx.cmd_options['user_data'] = userdata
49
+ return Builder(ctx).generate_runtime_key()
50
+
51
+
52
+ def register_pyarmor(ctx, regfile):
53
+ reg = Register(ctx)
54
+ logging.info('register "%s"', regfile)
55
+ reg.register_regfile(regfile)
56
+ if reg.license_info['features'] < 15:
57
+ raise RuntimeError('this feature is only for group license')
58
+
59
+ machid = reg._get_machine_id()
60
+ logging.debug('machine id: %s', machid)
61
+ DockerAuthHandler.MACHID = machid
62
+
63
+ Pytransform3._update_token(ctx)
64
+
65
+
66
+ def main_entry():
67
+ parser = argparse.ArgumentParser()
68
+ parser.add_argument('-p', '--port', type=int, default=PORT)
69
+ parser.add_argument('-s', '--sock', default='/var/run/docker.sock',
70
+ help=argparse.SUPPRESS)
71
+ parser.add_argument('--home', help=argparse.SUPPRESS)
72
+ parser.add_argument('regfile', nargs=1,
73
+ help='group device registration file for this machine')
74
+ args = parser.parse_args(sys.argv[1:])
75
+
76
+ home = DockerAuthHandler.WORKPATH
77
+ if args.home:
78
+ DockerAuthHandler.WORKPATH = args.home
79
+ home = args.home
80
+ logging.info('work path: %s', home)
81
+
82
+ ctx = Context(home=os.path.expanduser(home))
83
+ register_pyarmor(ctx, args.regfile[0])
84
+ DockerAuthHandler.CTX = ctx
85
+
86
+ host, port = '0.0.0.0', args.port
87
+ with socketserver.TCPServer((host, port), DockerAuthHandler) as server:
88
+ logging.info('listen docker auth request on %s:%s', host, args.port)
89
+ server.serve_forever()
90
+
91
+
92
+ def main():
93
+ logging.basicConfig(
94
+ level=logging.INFO,
95
+ format='%(asctime)s: %(message)s',
96
+ )
97
+ main_entry()
98
+
99
+
100
+ if __name__ == '__main__':
101
+ main()
@@ -153,11 +153,17 @@ class Register(object):
153
153
  f.extract(item, path=path)
154
154
  namelist = f.namelist()
155
155
  if 'group.tokens' in namelist:
156
- machid = self._get_machine_id()
157
- name = '/'.join(['tokens', machid.decode('utf-8')])
156
+ machid = self._get_machine_id().decode('utf-8')
157
+ name = '/'.join(['tokens', machid])
158
158
  if name not in namelist:
159
- logger.debug('no found "%s" in offline regfile', name)
160
- raise CliError('this regfile is not for this device')
159
+ machid = self._get_docker_hostname()
160
+ if not machid:
161
+ raise CliError('could not get docker host machine id')
162
+ hostname = '/'.join(['tokens', machid])
163
+ if hostname not in namelist:
164
+ logger.debug('no found "%s" in offline regfile', name)
165
+ raise CliError('this regfile is not for this device')
166
+ name = hostname
161
167
  logger.debug('extracting %s', name)
162
168
  self.ctx.save_token(f.read(name))
163
169
  return
@@ -168,9 +174,26 @@ class Register(object):
168
174
  logger.info('update license token')
169
175
  self.update_token()
170
176
 
177
+ def _get_docker_hostname(self):
178
+ try:
179
+ from socket import socket, AF_INET, SOCK_STREAM
180
+ host = 'host.docker.internal'
181
+ port = 29092
182
+ with socket(AF_INET, SOCK_STREAM) as s:
183
+ s.connect((host, port))
184
+ s.sendall(b'PADH' + b'x' * 60)
185
+ flag = s.recv(1)
186
+ if flag in (b'a', b'b'):
187
+ data = s.recv(32)
188
+ machid = (flag + data).decode('utf-8')
189
+ logger.info('got docker host machine id: %s', machid)
190
+ return machid
191
+ except Exception:
192
+ logger.exception('could not get docker host machine id')
193
+
171
194
  def _get_machine_id(self):
172
195
  from .core import Pytransform3
173
- return Pytransform3.get_hd_info(10)
196
+ return Pytransform3.get_hd_info(11)
174
197
 
175
198
  def generate_group_device(self, devid):
176
199
  path = self.ctx.group_device_file(devid)
@@ -134,7 +134,8 @@ class CArchiveWriter2(CArchiveWriter):
134
134
  return
135
135
 
136
136
  with tempfile.TemporaryDirectory() as tmpdir:
137
- pathname = os.path.join(tmpdir, name)
137
+ pathname = os.path.join(tmpdir,
138
+ name.replace('/', '_').replace('\\', '_'))
138
139
  with open(pathname, 'wb') as f:
139
140
  f.write(rawdata)
140
141
  if typecode in (PKG_ITEM_PYSOURCE, PKG_ITEM_PYMODULE,
@@ -1,6 +1,6 @@
1
1
  from sys import platform
2
2
 
3
- version = '8.2.7'
3
+ version = '8.2.9'
4
4
 
5
5
  # The corresponding version of pytransform.so
6
6
  core_version = 'r52.6'