pywebexec 1.7.13__tar.gz → 1.7.14__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.
Files changed (51) hide show
  1. {pywebexec-1.7.13/pywebexec.egg-info → pywebexec-1.7.14}/PKG-INFO +2 -2
  2. {pywebexec-1.7.13 → pywebexec-1.7.14}/README.md +1 -1
  3. pywebexec-1.7.14/pywebexec/host_ip.py +47 -0
  4. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/pywebexec.py +3 -35
  5. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/commands.js +5 -1
  6. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/version.py +2 -2
  7. {pywebexec-1.7.13 → pywebexec-1.7.14/pywebexec.egg-info}/PKG-INFO +2 -2
  8. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec.egg-info/SOURCES.txt +1 -0
  9. {pywebexec-1.7.13 → pywebexec-1.7.14}/.github/workflows/python-publish.yml +0 -0
  10. {pywebexec-1.7.13 → pywebexec-1.7.14}/.gitignore +0 -0
  11. {pywebexec-1.7.13 → pywebexec-1.7.14}/LICENSE +0 -0
  12. {pywebexec-1.7.13 → pywebexec-1.7.14}/pyproject.toml +0 -0
  13. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/__init__.py +0 -0
  14. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/css/Consolas NF.ttf +0 -0
  15. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/css/style.css +0 -0
  16. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/css/xterm.css +0 -0
  17. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/aborted.svg +0 -0
  18. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/copy.svg +0 -0
  19. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/copy_ok.svg +0 -0
  20. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/down-arrow.svg +0 -0
  21. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/failed.svg +0 -0
  22. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/favicon.svg +0 -0
  23. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/fit-tty.svg +0 -0
  24. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/fit-win.svg +0 -0
  25. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/font-decrease.svg +0 -0
  26. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/font-increase.svg +0 -0
  27. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/norun.svg +0 -0
  28. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/pause.svg +0 -0
  29. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/popup.svg +0 -0
  30. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/resume.svg +0 -0
  31. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/running.svg +0 -0
  32. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/images/success.svg +0 -0
  33. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/popup.js +0 -0
  34. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/script.js +0 -0
  35. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/LICENSE +0 -0
  36. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/addon-canvas.js +0 -0
  37. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/addon-canvas.js.map +0 -0
  38. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/addon-fit.js +0 -0
  39. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/addon-fit.js.map +0 -0
  40. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/addon-unicode11.js +0 -0
  41. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/addon-unicode11.js.map +0 -0
  42. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/xterm.js +0 -0
  43. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/static/js/xterm/xterm.js.map +0 -0
  44. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/templates/__init__.py +0 -0
  45. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/templates/index.html +0 -0
  46. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec/templates/popup.html +0 -0
  47. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec.egg-info/dependency_links.txt +0 -0
  48. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec.egg-info/entry_points.txt +0 -0
  49. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec.egg-info/requires.txt +0 -0
  50. {pywebexec-1.7.13 → pywebexec-1.7.14}/pywebexec.egg-info/top_level.txt +0 -0
  51. {pywebexec-1.7.13 → pywebexec-1.7.14}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.7.13
3
+ Version: 1.7.14
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -205,4 +205,4 @@ $ curl http://myhost:8080/command_output/<command_id> -H "Accept: text/plain"
205
205
  | GET | /commands | | array of<br>command_id: uuid<br>command: str<br>start_time: isotime<br>end_time: isotime<br>status: str<br>exit_code: int<br>last_output_line: str |
206
206
  | GET | /executables | | array of str |
207
207
  | GET | /command_output/command_id | offset: int | output: str<br>status: str<br>links: { next: str } |
208
- | GET | /command_output_raw/command_id | offset: int | output: stream raw output until end of command<br>curl -N -s http://srv/command_output_raw/command_id|
208
+ | GET | /command_output_raw/command_id | offset: int | output: stream raw output until end of command<br>curl -Ns http://srv/command_output_raw/command_id|
@@ -142,4 +142,4 @@ $ curl http://myhost:8080/command_output/<command_id> -H "Accept: text/plain"
142
142
  | GET | /commands | | array of<br>command_id: uuid<br>command: str<br>start_time: isotime<br>end_time: isotime<br>status: str<br>exit_code: int<br>last_output_line: str |
143
143
  | GET | /executables | | array of str |
144
144
  | GET | /command_output/command_id | offset: int | output: str<br>status: str<br>links: { next: str } |
145
- | GET | /command_output_raw/command_id | offset: int | output: stream raw output until end of command<br>curl -N -s http://srv/command_output_raw/command_id|
145
+ | GET | /command_output_raw/command_id | offset: int | output: stream raw output until end of command<br>curl -Ns http://srv/command_output_raw/command_id|
@@ -0,0 +1,47 @@
1
+ from socket import gethostname, gethostbyname_ex, gethostbyaddr, inet_aton, inet_ntoa
2
+
3
+ def resolve_hostname(host):
4
+ """try get fqdn from DNS/hosts"""
5
+ try:
6
+ hostinfo = gethostbyname_ex(host)
7
+ for ip in hostinfo[2]:
8
+ if not ip.startswith('127.') or host in ('localhost', 'localhost.localdomain'):
9
+ return (hostinfo[0].rstrip('.'), ip)
10
+ return (host, host)
11
+ except OSError:
12
+ return (host, host)
13
+
14
+
15
+ def resolve_ip(ip):
16
+ """try resolve hostname by reverse dns query on ip addr"""
17
+ ip = inet_ntoa(inet_aton(ip))
18
+ try:
19
+ ipinfo = gethostbyaddr(ip)
20
+ return (ipinfo[0].rstrip('.'), ipinfo[2][0])
21
+ except OSError:
22
+ return (ip, ip)
23
+
24
+
25
+ def is_ip(host):
26
+ """determine if host is valid ip"""
27
+ try:
28
+ inet_aton(host)
29
+ return True
30
+ except OSError:
31
+ return False
32
+
33
+
34
+ def resolve(host_or_ip):
35
+ """resolve hostname from ip / hostname"""
36
+ if is_ip(host_or_ip):
37
+ return resolve_ip(host_or_ip)
38
+ return resolve_hostname(host_or_ip)
39
+
40
+
41
+ def get_host_ip(host_or_ip='0.0.0.0'):
42
+ if host_or_ip == '0.0.0.0':
43
+ return resolve(gethostname())
44
+ return resolve(host_or_ip)
45
+
46
+ if __name__ == '__main__':
47
+ print(get_host_ip())
@@ -13,7 +13,7 @@ import time
13
13
  import shlex
14
14
  from gunicorn.app.base import Application
15
15
  import ipaddress
16
- from socket import socket, gethostname, gethostbyname_ex, gethostbyaddr, inet_aton, inet_ntoa, AF_INET, SOCK_STREAM
16
+ from socket import socket, AF_INET, SOCK_STREAM
17
17
  import ssl
18
18
  import re
19
19
  import pwd
@@ -26,6 +26,7 @@ import struct
26
26
  import subprocess
27
27
  import logging
28
28
  import pyte
29
+ from host_ip import get_host_ip
29
30
 
30
31
  if os.environ.get('PYWEBEXEC_LDAP_SERVER'):
31
32
  from ldap3 import Server, Connection, ALL, SIMPLE, SUBTREE, Tls
@@ -69,39 +70,6 @@ def generate_random_password(length=12):
69
70
  return ''.join(random.choice(characters) for i in range(length))
70
71
 
71
72
 
72
- def resolve_hostname(host):
73
- """try get fqdn from DNS/hosts"""
74
- try:
75
- hostinfo = gethostbyname_ex(host)
76
- return (hostinfo[0].rstrip('.'), hostinfo[2][0])
77
- except OSError:
78
- return (host, host)
79
-
80
-
81
- def resolve_ip(ip):
82
- """try resolve hostname by reverse dns query on ip addr"""
83
- ip = inet_ntoa(inet_aton(ip))
84
- try:
85
- ipinfo = gethostbyaddr(ip)
86
- return (ipinfo[0].rstrip('.'), ipinfo[2][0])
87
- except OSError:
88
- return (ip, ip)
89
-
90
-
91
- def is_ip(host):
92
- """determine if host is valid ip"""
93
- try:
94
- inet_aton(host)
95
- return True
96
- except OSError:
97
- return False
98
-
99
-
100
- def resolve(host_or_ip):
101
- """resolve hostname from ip / hostname"""
102
- if is_ip(host_or_ip):
103
- return resolve_ip(host_or_ip)
104
- return resolve_hostname(host_or_ip)
105
73
 
106
74
 
107
75
  def generate_selfsigned_cert(hostname, ip_addresses=None, key=None):
@@ -397,7 +365,7 @@ def parseargs():
397
365
  COMMAND_STATUS_DIR = f"{os.getcwd()}/{COMMAND_STATUS_DIR}"
398
366
  sys.exit(start_term())
399
367
 
400
- (hostname, ip) = resolve(gethostname()) if args.listen == '0.0.0.0' else resolve(args.listen)
368
+ (hostname, ip) = get_host_ip(args.listen)
401
369
 
402
370
  if args.tokenurl:
403
371
  token = os.environ.get("PYWEBEXEC_TOKEN", token_urlsafe())
@@ -171,7 +171,11 @@ commandInput.addEventListener('click', () => {
171
171
  });
172
172
 
173
173
  commandInput.addEventListener('blur', (event) => {
174
- if (event.relatedTarget === showCommandListButton || event.relatedTarget === commandListDiv || event.relatedTarget.classList.includes('command-item')) {
174
+ if (
175
+ event.relatedTarget === showCommandListButton ||
176
+ event.relatedTarget === commandListDiv ||
177
+ (event.relatedTarget && event.relatedTarget.classList && event.relatedTarget.classList.contains('command-item'))
178
+ ) {
175
179
  event.preventDefault();
176
180
  return;
177
181
  }
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.7.13'
21
- __version_tuple__ = version_tuple = (1, 7, 13)
20
+ __version__ = version = '1.7.14'
21
+ __version_tuple__ = version_tuple = (1, 7, 14)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.7.13
3
+ Version: 1.7.14
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -205,4 +205,4 @@ $ curl http://myhost:8080/command_output/<command_id> -H "Accept: text/plain"
205
205
  | GET | /commands | | array of<br>command_id: uuid<br>command: str<br>start_time: isotime<br>end_time: isotime<br>status: str<br>exit_code: int<br>last_output_line: str |
206
206
  | GET | /executables | | array of str |
207
207
  | GET | /command_output/command_id | offset: int | output: str<br>status: str<br>links: { next: str } |
208
- | GET | /command_output_raw/command_id | offset: int | output: stream raw output until end of command<br>curl -N -s http://srv/command_output_raw/command_id|
208
+ | GET | /command_output_raw/command_id | offset: int | output: stream raw output until end of command<br>curl -Ns http://srv/command_output_raw/command_id|
@@ -5,6 +5,7 @@ pyproject.toml
5
5
  setup.cfg
6
6
  .github/workflows/python-publish.yml
7
7
  pywebexec/__init__.py
8
+ pywebexec/host_ip.py
8
9
  pywebexec/pywebexec.py
9
10
  pywebexec/version.py
10
11
  pywebexec.egg-info/PKG-INFO
File without changes
File without changes
File without changes
File without changes