pyarmor 8.2.8__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.8 → pyarmor-8.2.9}/PKG-INFO +1 -1
  2. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/__init__.py +1 -1
  3. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/__main__.py +3 -4
  4. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/default.cfg +3 -3
  5. pyarmor-8.2.9/pyarmor/cli/docker.py +148 -0
  6. pyarmor-8.2.8/src/cli/docker.py → pyarmor-8.2.9/pyarmor/cli/group.py +2 -54
  7. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/register.py +3 -1
  8. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/config.py +1 -1
  9. pyarmor-8.2.9/pyarmor/pyarmor-deprecated.py +843 -0
  10. pyarmor-8.2.9/pyarmor/pyimcore.py +65 -0
  11. {pyarmor-8.2.8 → pyarmor-8.2.9}/pyarmor.egg-info/PKG-INFO +1 -1
  12. pyarmor-8.2.9/pyarmor.egg-info/SOURCES.txt +115 -0
  13. {pyarmor-8.2.8 → pyarmor-8.2.9}/pyarmor.egg-info/entry_points.txt +1 -0
  14. pyarmor-8.2.9/pyarmor.egg-info/requires.txt +1 -0
  15. {pyarmor-8.2.8 → pyarmor-8.2.9}/setup.py +3 -2
  16. pyarmor-8.2.8/pyarmor.egg-info/SOURCES.txt +0 -112
  17. pyarmor-8.2.8/pyarmor.egg-info/requires.txt +0 -1
  18. {pyarmor-8.2.8 → pyarmor-8.2.9}/MANIFEST.in +0 -0
  19. {pyarmor-8.2.8 → pyarmor-8.2.9}/README.md +0 -0
  20. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/README.rst +0 -0
  21. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/__init__.py +0 -0
  22. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/benchmark.py +0 -0
  23. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/build_meta.py +0 -0
  24. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/bootstrap.py +0 -0
  25. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/config.py +0 -0
  26. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/context.py +0 -0
  27. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/generate.py +0 -0
  28. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/merge.py +0 -0
  29. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/mixer.py +0 -0
  30. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/plugin.py +0 -0
  31. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/public_capsule.zip +0 -0
  32. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/repack.py +0 -0
  33. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/resource.py +0 -0
  34. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cli/shell.py +0 -0
  35. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/cobuilder.py +0 -0
  36. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/README-ZH.md +0 -0
  37. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/README.md +0 -0
  38. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/build-for-exe.bat +0 -0
  39. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/build-for-freeze.bat +0 -0
  40. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/build-with-project.bat +0 -0
  41. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/build-with-project.sh +0 -0
  42. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/cx_Freeze/hello.py +0 -0
  43. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/cx_Freeze/queens.py +0 -0
  44. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/cx_Freeze/setup.py +0 -0
  45. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/helloworld/foo.py +0 -0
  46. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-app.bat +0 -0
  47. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-app.sh +0 -0
  48. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-pkg.bat +0 -0
  49. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/obfuscate-pkg.sh +0 -0
  50. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pack-obfuscated-scripts.bat +0 -0
  51. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pack-obfuscated-scripts.sh +0 -0
  52. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/py2exe/hello.py +0 -0
  53. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/py2exe/queens.py +0 -0
  54. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/py2exe/setup.py +0 -0
  55. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Arithmetic.py +0 -0
  56. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Calls.py +0 -0
  57. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/CommandLine.py +0 -0
  58. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Constructs.py +0 -0
  59. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Dict.py +0 -0
  60. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Exceptions.py +0 -0
  61. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Imports.py +0 -0
  62. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Instances.py +0 -0
  63. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Lists.py +0 -0
  64. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Lookups.py +0 -0
  65. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/NewInstances.py +0 -0
  66. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Numbers.py +0 -0
  67. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Setup.py +0 -0
  68. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Strings.py +0 -0
  69. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/Tuples.py +0 -0
  70. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/With.py +0 -0
  71. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/clockres.py +0 -0
  72. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/package/__init__.py +0 -0
  73. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/package/submodule.py +0 -0
  74. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/pybench.py +0 -0
  75. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/pybench/systimes.py +0 -0
  76. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/simple/queens.py +0 -0
  77. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/testmod/hello.py +0 -0
  78. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/testmod/queens.py +0 -0
  79. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/testpkg/main.py +0 -0
  80. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/testpkg/mypkg/__init__.py +0 -0
  81. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/examples/testpkg/mypkg/foo.py +0 -0
  82. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/__init__.py +0 -0
  83. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/build_data_module.py +0 -0
  84. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/buildext.py +0 -0
  85. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/get_bind_key.py +0 -0
  86. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/get_license_info.py +0 -0
  87. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/get_platform_name.py +0 -0
  88. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/merge.py +0 -0
  89. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/repack.py +0 -0
  90. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/helper/superuntime.py +0 -0
  91. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/license.tri +0 -0
  92. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/packer.py +0 -0
  93. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/platforms/darwin/x86_64/_pytransform.dylib +0 -0
  94. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/platforms/linux/x86/_pytransform.so +0 -0
  95. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/platforms/linux/x86_64/_pytransform.so +0 -0
  96. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/platforms/windows/x86/_pytransform.dll +0 -0
  97. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/platforms/windows/x86_64/_pytransform.dll +0 -0
  98. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/plugins/README.md +0 -0
  99. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/plugins/check_ntp_time.py +0 -0
  100. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/polyfills/__init__.py +0 -0
  101. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/polyfills/argparse.py +0 -0
  102. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/product.key +0 -0
  103. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/project.py +0 -0
  104. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/protect_code.pt +0 -0
  105. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/protect_code2.pt +0 -0
  106. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/public.key +0 -0
  107. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/public_capsule.zip +0 -0
  108. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/pyarmor-webui.py +0 -0
  109. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/pyarmor.py +0 -0
  110. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/pyshield.key +0 -0
  111. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/pyshield.lic +0 -0
  112. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/pytransform.py +0 -0
  113. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/reform.py +0 -0
  114. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/register.py +0 -0
  115. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/sppmode.py +0 -0
  116. {pyarmor-8.2.8/src → pyarmor-8.2.9/pyarmor}/utils.py +0 -0
  117. {pyarmor-8.2.8 → pyarmor-8.2.9}/pyarmor.egg-info/dependency_links.txt +0 -0
  118. {pyarmor-8.2.8 → pyarmor-8.2.9}/pyarmor.egg-info/top_level.txt +0 -0
  119. {pyarmor-8.2.8 → 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.8
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.8'
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)
@@ -3,10 +3,10 @@
3
3
  ;; Pyarmor version
4
4
  major = 8
5
5
  minor = 2
6
- patch = 8
6
+ patch = 9
7
7
 
8
8
  ;; Core version
9
- cli.core = 3.2.8
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()
@@ -5,8 +5,6 @@ import socketserver
5
5
  import struct
6
6
  import sys
7
7
 
8
- import docker
9
-
10
8
  from .context import Context
11
9
  from .generate import Builder, Pytransform3
12
10
  from .register import Register
@@ -14,20 +12,10 @@ from .register import Register
14
12
  PORT = 29092
15
13
 
16
14
 
17
- def get_docker_gateway(client):
18
- filters = {
19
- 'driver': 'bridge',
20
- 'type': 'builtin'
21
- }
22
- networks = client.networks.list(filters=filters)
23
- return networks[0].attrs['IPAM']['Config'][0]['Gateway']
24
-
25
-
26
15
  class DockerAuthHandler(socketserver.BaseRequestHandler):
27
16
 
28
17
  WORKPATH = os.path.expanduser(os.path.join('~', '.pyarmor', 'docker'))
29
18
  CTX = None
30
- CLIENT = None
31
19
 
32
20
  def handle(self):
33
21
  data = self.request.recv(64)
@@ -42,33 +30,10 @@ class DockerAuthHandler(socketserver.BaseRequestHandler):
42
30
  msg += b'\00'
43
31
  self.request.send(struct.pack('!HH', 1, len(msg)) + msg)
44
32
 
45
- def copy_file_into_docker(self, containerid, filename):
46
- from subprocess import check_call
47
- check_call(['docker', 'cp', filename, '%s:/' % containerid])
48
-
49
- def get_container_info(self, client, shortid):
50
- try:
51
- container = client.container.get(shortid)
52
- return container.attrs
53
- except docker.errors.NotFound:
54
- pass
55
- except docker.errors.APIError:
56
- pass
57
-
58
33
  def process(self, packet):
59
34
  if packet[:4] == b'PADH':
60
35
  self.request.send(self.MACHID)
61
- return
62
-
63
- container = self.get_container(self.client_address[0])
64
- state = container.attrs['State']
65
- if state.get('Status') == 'running' and state.get('Running'):
66
- # 2023-06-15T23:51:03.287483366Z
67
- # state.get('StartedAt')
68
- # bridge = container.attrs['NetworkSettings']['Networks']['bridge']
69
- # bridge['MacAddress']
70
- # bridge['Gateway'] and bridge['IPAddress']
71
- # bridge['IPv6Gateway'] and bridge['GlobalIPv6Address']
36
+ else:
72
37
  userdata = self.parse_packet(packet)
73
38
  keydata = self.generate_runtime_key(userdata.decode('utf-8'))
74
39
  self.request.send(struct.pack('!HH', 0, len(keydata)) + keydata)
@@ -83,20 +48,6 @@ class DockerAuthHandler(socketserver.BaseRequestHandler):
83
48
  ctx.cmd_options['user_data'] = userdata
84
49
  return Builder(ctx).generate_runtime_key()
85
50
 
86
- def get_container(self, ipaddr):
87
- filters = {
88
- 'driver': 'bridge',
89
- 'type': 'builtin'
90
- }
91
- networks = self.CLIENT.networks.list(filters=filters, greedy=True)
92
- containers = networks[0].attrs.get('Containers')
93
- if containers:
94
- marker = ipaddr + '/'
95
- for dockid, netattr in containers.items():
96
- if netattr.get('IPv4Address').startswith(marker):
97
- return self.CLIENT.containers.get(dockid)
98
- raise RuntimeError('no found countainer with IPv4 %s' % ipaddr)
99
-
100
51
 
101
52
  def register_pyarmor(ctx, regfile):
102
53
  reg = Register(ctx)
@@ -132,10 +83,7 @@ def main_entry():
132
83
  register_pyarmor(ctx, args.regfile[0])
133
84
  DockerAuthHandler.CTX = ctx
134
85
 
135
- client = docker.from_env()
136
- host, port = get_docker_gateway(client), args.port
137
- DockerAuthHandler.CLIENT = client
138
-
86
+ host, port = '0.0.0.0', args.port
139
87
  with socketserver.TCPServer((host, port), DockerAuthHandler) as server:
140
88
  logging.info('listen docker auth request on %s:%s', host, args.port)
141
89
  server.serve_forever()
@@ -157,6 +157,8 @@ class Register(object):
157
157
  name = '/'.join(['tokens', machid])
158
158
  if name not in namelist:
159
159
  machid = self._get_docker_hostname()
160
+ if not machid:
161
+ raise CliError('could not get docker host machine id')
160
162
  hostname = '/'.join(['tokens', machid])
161
163
  if hostname not in namelist:
162
164
  logger.debug('no found "%s" in offline regfile', name)
@@ -187,7 +189,7 @@ class Register(object):
187
189
  logger.info('got docker host machine id: %s', machid)
188
190
  return machid
189
191
  except Exception:
190
- pass
192
+ logger.exception('could not get docker host machine id')
191
193
 
192
194
  def _get_machine_id(self):
193
195
  from .core import Pytransform3
@@ -1,6 +1,6 @@
1
1
  from sys import platform
2
2
 
3
- version = '8.2.8'
3
+ version = '8.2.9'
4
4
 
5
5
  # The corresponding version of pytransform.so
6
6
  core_version = 'r52.6'