NitroExpose 2.0__tar.gz → 2.1__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.

Potentially problematic release.


This version of NitroExpose might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NitroExpose
3
- Version: 2.0
3
+ Version: 2.1
4
4
  Summary: Advanced CLI To Expose Port To Your Domain.
5
5
  Home-page: https://github.com/yuvrajmodz/NitroExpose
6
6
  Author: @NacDevs
@@ -25,7 +25,7 @@ Dynamic: summary
25
25
 
26
26
  ## NitroExpose
27
27
 
28
- **Letest Version:** 2.0
28
+ **Letest Version:** 2.1
29
29
  **Developer:** @Nactire
30
30
  **Git Repo:** [NitroExpose](https://github.com/yuvrajmodz/NitroExpose)
31
31
 
@@ -56,21 +56,12 @@ It provides a **one-command deployment system** for developers who want to run t
56
56
  - **apt** Package Manager Required
57
57
 
58
58
 
59
- ## 🌐 Module installation
59
+ ## 🌊 Module installation
60
60
 
61
61
  ```bash
62
62
  pip install NitroExpose --break-system-packages
63
63
  ```
64
64
 
65
- ## 🌊 Optional installation
66
-
67
- ```bash
68
- sudo apt update -y
69
- sudo apt install nginx -y
70
- sudo apt install certbot -y
71
- sudo apt install python3-certbot-nginx -y
72
- ```
73
-
74
65
  ## 🧭 Usage Guide
75
66
 
76
67
  Step 1 – Point Your Vps/Server IP in Your Domain Records:
@@ -80,25 +71,39 @@ Step 1 – Point Your Vps/Server IP in Your Domain Records:
80
71
  **IPv4**: Your Vps Server IP
81
72
  **TTL**: Auto
82
73
 
83
-
84
74
  Step 2 – **Launch NitroExpose**
85
75
  ```bash
86
76
  NitroExpose
87
77
  ```
88
78
 
89
-
90
79
  Step 3 – **Enter Your Domain Or Subdomain**
91
80
  ```bash
92
81
  ┌─╼ Enter Domain Or Subdomain
93
82
  └────╼ ❯❯❯ myproject.example.com
94
83
  ```
95
84
 
96
-
97
85
  Step 4 – **Enter the Local Port to Expose**
98
86
  ```bash
99
87
  ┌─╼ Enter Port To Expose
100
88
  └────╼ ❯❯❯ 8000
101
89
  ```
102
90
 
91
+ ✨ **Now it Will Take 8 to 9 Seconds For Verification And Then Boom! Your Local Port Successfully Exposed To Your Public Domain/Subdomain**.
92
+
93
+ ## 🎯 To Remove Domain/Subdomain
94
+
95
+ ```bash
96
+ NitroExpose remove <domain/subdomain>
97
+ ```
98
+
99
+ ## 🎯 Domain/Subdomain Remove Example
103
100
 
104
- ✨ **Now it Will Take 8 to 9 Seconds For Verification And Then Boom! Your Local Port Successfully Exposed To Your Public Domain/Subdomain**.
101
+ ```bash
102
+ NitroExpose remove myproject.example.com
103
+ ```
104
+
105
+ ## To Check Package Version
106
+
107
+ ```bash
108
+ NitroExpose --v
109
+ ```
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NitroExpose
3
- Version: 2.0
3
+ Version: 2.1
4
4
  Summary: Advanced CLI To Expose Port To Your Domain.
5
5
  Home-page: https://github.com/yuvrajmodz/NitroExpose
6
6
  Author: @NacDevs
@@ -25,7 +25,7 @@ Dynamic: summary
25
25
 
26
26
  ## NitroExpose
27
27
 
28
- **Letest Version:** 2.0
28
+ **Letest Version:** 2.1
29
29
  **Developer:** @Nactire
30
30
  **Git Repo:** [NitroExpose](https://github.com/yuvrajmodz/NitroExpose)
31
31
 
@@ -56,21 +56,12 @@ It provides a **one-command deployment system** for developers who want to run t
56
56
  - **apt** Package Manager Required
57
57
 
58
58
 
59
- ## 🌐 Module installation
59
+ ## 🌊 Module installation
60
60
 
61
61
  ```bash
62
62
  pip install NitroExpose --break-system-packages
63
63
  ```
64
64
 
65
- ## 🌊 Optional installation
66
-
67
- ```bash
68
- sudo apt update -y
69
- sudo apt install nginx -y
70
- sudo apt install certbot -y
71
- sudo apt install python3-certbot-nginx -y
72
- ```
73
-
74
65
  ## 🧭 Usage Guide
75
66
 
76
67
  Step 1 – Point Your Vps/Server IP in Your Domain Records:
@@ -80,25 +71,39 @@ Step 1 – Point Your Vps/Server IP in Your Domain Records:
80
71
  **IPv4**: Your Vps Server IP
81
72
  **TTL**: Auto
82
73
 
83
-
84
74
  Step 2 – **Launch NitroExpose**
85
75
  ```bash
86
76
  NitroExpose
87
77
  ```
88
78
 
89
-
90
79
  Step 3 – **Enter Your Domain Or Subdomain**
91
80
  ```bash
92
81
  ┌─╼ Enter Domain Or Subdomain
93
82
  └────╼ ❯❯❯ myproject.example.com
94
83
  ```
95
84
 
96
-
97
85
  Step 4 – **Enter the Local Port to Expose**
98
86
  ```bash
99
87
  ┌─╼ Enter Port To Expose
100
88
  └────╼ ❯❯❯ 8000
101
89
  ```
102
90
 
91
+ ✨ **Now it Will Take 8 to 9 Seconds For Verification And Then Boom! Your Local Port Successfully Exposed To Your Public Domain/Subdomain**.
92
+
93
+ ## 🎯 To Remove Domain/Subdomain
94
+
95
+ ```bash
96
+ NitroExpose remove <domain/subdomain>
97
+ ```
98
+
99
+ ## 🎯 Domain/Subdomain Remove Example
103
100
 
104
- ✨ **Now it Will Take 8 to 9 Seconds For Verification And Then Boom! Your Local Port Successfully Exposed To Your Public Domain/Subdomain**.
101
+ ```bash
102
+ NitroExpose remove myproject.example.com
103
+ ```
104
+
105
+ ## To Check Package Version
106
+
107
+ ```bash
108
+ NitroExpose --v
109
+ ```
@@ -1,6 +1,6 @@
1
1
  ## NitroExpose
2
2
 
3
- **Letest Version:** 2.0
3
+ **Letest Version:** 2.1
4
4
  **Developer:** @Nactire
5
5
  **Git Repo:** [NitroExpose](https://github.com/yuvrajmodz/NitroExpose)
6
6
 
@@ -31,21 +31,12 @@ It provides a **one-command deployment system** for developers who want to run t
31
31
  - **apt** Package Manager Required
32
32
 
33
33
 
34
- ## 🌐 Module installation
34
+ ## 🌊 Module installation
35
35
 
36
36
  ```bash
37
37
  pip install NitroExpose --break-system-packages
38
38
  ```
39
39
 
40
- ## 🌊 Optional installation
41
-
42
- ```bash
43
- sudo apt update -y
44
- sudo apt install nginx -y
45
- sudo apt install certbot -y
46
- sudo apt install python3-certbot-nginx -y
47
- ```
48
-
49
40
  ## 🧭 Usage Guide
50
41
 
51
42
  Step 1 – Point Your Vps/Server IP in Your Domain Records:
@@ -55,25 +46,39 @@ Step 1 – Point Your Vps/Server IP in Your Domain Records:
55
46
  **IPv4**: Your Vps Server IP
56
47
  **TTL**: Auto
57
48
 
58
-
59
49
  Step 2 – **Launch NitroExpose**
60
50
  ```bash
61
51
  NitroExpose
62
52
  ```
63
53
 
64
-
65
54
  Step 3 – **Enter Your Domain Or Subdomain**
66
55
  ```bash
67
56
  ┌─╼ Enter Domain Or Subdomain
68
57
  └────╼ ❯❯❯ myproject.example.com
69
58
  ```
70
59
 
71
-
72
60
  Step 4 – **Enter the Local Port to Expose**
73
61
  ```bash
74
62
  ┌─╼ Enter Port To Expose
75
63
  └────╼ ❯❯❯ 8000
76
64
  ```
77
65
 
66
+ ✨ **Now it Will Take 8 to 9 Seconds For Verification And Then Boom! Your Local Port Successfully Exposed To Your Public Domain/Subdomain**.
78
67
 
79
- **Now it Will Take 8 to 9 Seconds For Verification And Then Boom! Your Local Port Successfully Exposed To Your Public Domain/Subdomain**.
68
+ ## 🎯 To Remove Domain/Subdomain
69
+
70
+ ```bash
71
+ NitroExpose remove <domain/subdomain>
72
+ ```
73
+
74
+ ## 🎯 Domain/Subdomain Remove Example
75
+
76
+ ```bash
77
+ NitroExpose remove myproject.example.com
78
+ ```
79
+
80
+ ## To Check Package Version
81
+
82
+ ```bash
83
+ NitroExpose --v
84
+ ```
@@ -9,7 +9,9 @@ import time
9
9
  import requests
10
10
  import signal
11
11
  import socket
12
+ import importlib.metadata
12
13
 
14
+ # cli.py
13
15
  # 𝗠𝗮𝗻𝗮𝗴𝗲𝗱 𝗕𝘆 @Nactire
14
16
 
15
17
  def print_green(text):
@@ -23,19 +25,39 @@ def print_yellow(text):
23
25
 
24
26
  def print_turquoise(text):
25
27
  print("\033[38;2;0;255;234m" + text + "\033[0m")
28
+
29
+ def get_version():
30
+ try:
31
+ version = importlib.metadata.version('nitroexpose')
32
+ return version
33
+ except importlib.metadata.PackageNotFoundError:
34
+ return "Unknown"
26
35
 
27
36
  def run_command(cmd):
28
- process = subprocess.Popen(cmd, shell=True)
37
+ process = subprocess.Popen(
38
+ cmd,
39
+ shell=True,
40
+ stdout=subprocess.DEVNULL,
41
+ stderr=subprocess.DEVNULL
42
+ )
29
43
  process.wait()
30
44
  return process.returncode
31
45
 
32
46
  def is_installed(cmd):
33
- return subprocess.call(f"{cmd} > /dev/null 2>&1", shell=True) == 0
47
+ return subprocess.call(
48
+ f"{cmd} > /dev/null 2>&1",
49
+ shell=True,
50
+ stdout=subprocess.DEVNULL,
51
+ stderr=subprocess.DEVNULL
52
+ ) == 0
34
53
 
35
54
  def is_certbot_nginx_plugin_installed():
36
55
  try:
37
56
  result = subprocess.check_output(
38
- "dpkg -l | grep python3-certbot-nginx", shell=True, text=True
57
+ "dpkg -l | grep python3-certbot-nginx",
58
+ shell=True,
59
+ text=True,
60
+ stderr=subprocess.DEVNULL
39
61
  )
40
62
  return "python3-certbot-nginx" in result
41
63
  except subprocess.CalledProcessError:
@@ -92,34 +114,166 @@ def restricted_input(prompt, allowed_pattern):
92
114
  termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
93
115
  return buffer
94
116
 
117
+ def install_and_verify_package(package_name, check_cmd, install_cmds):
118
+ print_green(f"Installing {package_name} ...")
119
+
120
+ for cmd in install_cmds:
121
+ run_command(cmd)
122
+
123
+ if check_cmd():
124
+ print_green(f"{package_name} installed.")
125
+ return True
126
+ else:
127
+ print_red(f"{package_name} installing Error.")
128
+ sys.exit(1)
129
+
130
+ def is_valid_domain(domain):
131
+ if "http://" in domain or "https://" in domain or " " in domain:
132
+ return False
133
+
134
+ if "." not in domain:
135
+ return False
136
+
137
+ pattern = r'^[a-zA-Z0-9\.\-]+$'
138
+ if not re.match(pattern, domain):
139
+ return False
140
+
141
+ return True
142
+
143
+ def is_subdomain(domain):
144
+ parts = domain.split(".")
145
+ return len(parts) > 2
146
+
147
+ def remove_domain(domain):
148
+ if os.geteuid() != 0:
149
+ print_red("\nPlease Use Root Environment.\n")
150
+ sys.exit(1)
151
+
152
+ if not is_valid_domain(domain):
153
+ print_red("\nDomain Format Not Valid.\n")
154
+ sys.exit(1)
155
+
156
+ if not is_installed("nginx -v"):
157
+ install_and_verify_package(
158
+ "NGINX",
159
+ lambda: is_installed("nginx -v"),
160
+ [
161
+ "sudo apt update -o Acquire::AllowInsecureRepositories=true",
162
+ "sudo apt install -y nginx",
163
+ "sudo systemctl start nginx",
164
+ "sudo systemctl enable nginx"
165
+ ]
166
+ )
167
+ else:
168
+ print_green("NGINX installed.")
169
+
170
+ if not is_installed("certbot --version"):
171
+ install_and_verify_package(
172
+ "Certbot",
173
+ lambda: is_installed("certbot --version"),
174
+ [
175
+ "sudo apt update -o Acquire::AllowInsecureRepositories=true",
176
+ "sudo apt install -y certbot python3-certbot-nginx"
177
+ ]
178
+ )
179
+ else:
180
+ print_green("Certbot installed.")
181
+
182
+ if not is_certbot_nginx_plugin_installed():
183
+ install_and_verify_package(
184
+ "python3-certbot-nginx plugin",
185
+ is_certbot_nginx_plugin_installed,
186
+ [
187
+ "sudo apt update -o Acquire::AllowInsecureRepositories=true",
188
+ "sudo apt install -y python3-certbot-nginx"
189
+ ]
190
+ )
191
+ else:
192
+ print_green("python3-certbot-nginx plugin installed.")
193
+
194
+ print("\n")
195
+
196
+ available_path = f"/etc/nginx/sites-available/{domain}"
197
+ enabled_path = f"/etc/nginx/sites-enabled/{domain}"
198
+
199
+ available_exists = os.path.exists(available_path)
200
+ enabled_exists = os.path.exists(enabled_path)
201
+
202
+ domain_type = "Subdomain" if is_subdomain(domain) else "Domain"
203
+
204
+ if not available_exists and not enabled_exists:
205
+ run_command(f"sudo rm -f {available_path}")
206
+ run_command(f"sudo rm -f {enabled_path}")
207
+ run_command("sudo systemctl reload nginx")
208
+ print_red(f"Targeted {domain_type} Doesn't Exist in Your Server.\n")
209
+ sys.exit(1)
210
+ elif not available_exists or not enabled_exists:
211
+ run_command(f"sudo rm -f {available_path}")
212
+ run_command(f"sudo rm -f {enabled_path}")
213
+ run_command("sudo systemctl reload nginx")
214
+ print_red(f"Targeted {domain_type} Doesn't Exist in Your Server.\n")
215
+ sys.exit(1)
216
+ else:
217
+ run_command(f"sudo rm -f {available_path}")
218
+ run_command(f"sudo rm -f {enabled_path}")
219
+ run_command("sudo systemctl reload nginx")
220
+ print_green(f"\n{domain_type} Removed Successfully.\n")
221
+ sys.exit(0)
222
+
95
223
  def main():
224
+ if len(sys.argv) == 2 and sys.argv[1] in ["-v", "--v"]:
225
+ version = get_version()
226
+ print_green(f"V{version}")
227
+ sys.exit(0)
228
+
229
+ if len(sys.argv) == 3 and sys.argv[1] == "remove":
230
+ domain = sys.argv[2]
231
+ remove_domain(domain)
232
+ return
233
+
96
234
  if os.geteuid() != 0:
97
235
  print_red("\nPlease Use Root Environment.\n")
98
236
  sys.exit(1)
99
237
 
100
238
  if not is_installed("nginx -v"):
101
- print_green("Installing NGINX ...")
102
- run_command("sudo apt update -o Acquire::AllowInsecureRepositories=true")
103
- run_command("sudo apt install -y nginx")
104
- run_command("sudo systemctl start nginx")
105
- run_command("sudo systemctl enable nginx")
239
+ install_and_verify_package(
240
+ "NGINX",
241
+ lambda: is_installed("nginx -v"),
242
+ [
243
+ "sudo apt update -o Acquire::AllowInsecureRepositories=true",
244
+ "sudo apt install -y nginx",
245
+ "sudo systemctl start nginx",
246
+ "sudo systemctl enable nginx"
247
+ ]
248
+ )
106
249
  else:
107
250
  print_green("NGINX installed.")
108
251
 
109
252
  if not is_installed("certbot --version"):
110
- print_green("Installing Certbot ...")
111
- run_command("sudo apt update -o Acquire::AllowInsecureRepositories=true")
112
- run_command("sudo apt install -y certbot python3-certbot-nginx")
253
+ install_and_verify_package(
254
+ "Certbot",
255
+ lambda: is_installed("certbot --version"),
256
+ [
257
+ "sudo apt update -o Acquire::AllowInsecureRepositories=true",
258
+ "sudo apt install -y certbot python3-certbot-nginx"
259
+ ]
260
+ )
113
261
  else:
114
262
  print_green("Certbot installed.")
115
-
263
+
116
264
  if not is_certbot_nginx_plugin_installed():
117
- print_green("Installing python3-certbot-nginx plugin ...")
118
- run_command("sudo apt update -o Acquire::AllowInsecureRepositories=true")
119
- run_command("sudo apt install -y python3-certbot-nginx")
265
+ install_and_verify_package(
266
+ "python3-certbot-nginx plugin",
267
+ is_certbot_nginx_plugin_installed,
268
+ [
269
+ "sudo apt update -o Acquire::AllowInsecureRepositories=true",
270
+ "sudo apt install -y python3-certbot-nginx"
271
+ ]
272
+ )
120
273
  else:
121
274
  print_green("python3-certbot-nginx plugin installed.")
122
- print("\n")
275
+
276
+ print("\n")
123
277
 
124
278
  print_turquoise("┌─╼ Enter Domain Or Subdomain")
125
279
  domain = restricted_input("\033[38;2;0;255;234m└────╼ ❯❯❯ \033[0m", r"[a-zA-Z0-9\.\-]")
@@ -187,6 +341,8 @@ server {{
187
341
  run_command(f"sudo rm -f /etc/nginx/sites-available/{domain}")
188
342
  run_command(f"sudo rm -f /etc/nginx/sites-enabled/{domain}")
189
343
  run_command("sudo systemctl reload nginx")
344
+
345
+ print_yellow("SSL Cert installing...")
190
346
 
191
347
  nginx_conf = f"""
192
348
  server {{
@@ -213,7 +369,7 @@ server {{
213
369
  run_command(f"sudo certbot --nginx -d {domain} --non-interactive --agree-tos --email nitroexpose@gmail.com")
214
370
  run_command("sudo systemctl reload nginx")
215
371
 
216
- print_yellow("\nSSL Certificate Checking...")
372
+ print_yellow("SSL Certificate Checking...")
217
373
  time.sleep(2)
218
374
 
219
375
  ssl_installed = False
@@ -228,7 +384,7 @@ server {{
228
384
 
229
385
  print("\n")
230
386
  if ssl_installed:
231
- print_green(f"Exposed Successfully To Domain\n")
387
+ print_green(f"Exposed Successfully On Your Domain\n")
232
388
  print_green(f"Exposed On: https://{domain}\n")
233
389
  print_green(f"Port: {port}\n")
234
390
  print_green(f"SSL Installed Using Let's Encrypt.\n")
@@ -238,7 +394,7 @@ server {{
238
394
  print_yellow(f" * Please Star Our Project: https://github.com/yuvrajmodz/NitroExpose")
239
395
  print_yellow(f"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n")
240
396
  else:
241
- print_green(f"Exposed Successfully To Domain\n")
397
+ print_green(f"Exposed Successfully On Your Domain\n")
242
398
  print_green(f"Exposed On: http://{domain}\n")
243
399
  print_green(f"Port: {port}\n")
244
400
  print_yellow(f"Unfortunately, please verify your records carefully. Your server is exposed on your domain, and we are experiencing difficulties while attempting to install an SSL certificate.\n\n")
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="NitroExpose",
5
- version="2.0",
5
+ version="2.1",
6
6
  author="@NacDevs",
7
7
  author_email="yuvrajmodz@gmail.com",
8
8
  description="Advanced CLI To Expose Port To Your Domain.",
File without changes
File without changes
File without changes