Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
added all functions
Browse files Browse the repository at this point in the history
added all functions
added all functions
added all functions
added all functions
  • Loading branch information
mickoissicko committed Jan 26, 2024
1 parent 241714b commit 136ca62
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 70 deletions.
56 changes: 25 additions & 31 deletions bin_arc/script/ngroksenpai.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import subprocess
import requests
import json
Expand All @@ -7,7 +6,6 @@
import time

LOCK_FILE = "ngroksenpai.lock"
WEBHOOK_FILE_PATH = '../config/webhook.txt'

def check_lock_file():
return os.path.exists(LOCK_FILE)
Expand All @@ -27,39 +25,20 @@ def check_tunnel(curl_command, target_string):
return output
return None

# thx chatgpt lmao
def get_discord_webhook_url(file_path):
with open(file_path, 'r') as file:
return file.read().strip()

def send_discord_webhook(webhook_url, region, url):
message = f"* {region} === `{url}`"
payload = {"content": message}
requests.post(webhook_url, json=payload)

os.chdir('../config')
with open("conf.txt", "r") as conf_file:
conf_lines = conf_file.readlines()

use_ngrok = False
autongrok = False

for line in conf_lines:
if line.startswith("#"):
continue
parts = line.strip().split('=')
if len(parts) == 2:
key, value = parts[0].strip(), parts[1].strip()
if key == "use-ngrok" and value.lower() == "true":
use_ngrok = True
elif key == "autongrok" and value.lower() == "true":
autongrok = True

if autongrok:
starter_script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'starter.sh')
subprocess.Popen(['bash', starter_script_path])

time.sleep(10)
def read_config(file_path):
config = {}
with open(file_path, 'r') as file:
lines = file.readlines()
for line in lines:
if '=' in line:
key, value = line.strip().split('=')
config[key.strip()] = value.strip()
return config

def main():
if check_lock_file():
Expand All @@ -69,7 +48,13 @@ def main():
create_lock_file()

try:
discord_webhook_url = get_discord_webhook_url(WEBHOOK_FILE_PATH)
config = read_config('../config/conf.txt')

if config.get('autongrok') == 'True':
starter_script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'starter.sh')
subprocess.Popen(['bash', starter_script_path])
time.sleep(15)
print("WORKING")

curl_commands = [
"curl 127.0.0.1:4040/api/tunnels",
Expand All @@ -81,6 +66,15 @@ def main():

target_string = "tcp://"

webhook_file_path = '../config/webhook.txt'
if os.path.exists(webhook_file_path):
with open(webhook_file_path, 'r') as webhook_file:

discord_webhook_url = webhook_file.read().strip() # webhook func
else:
print("Error: webhook.txt not found. Please create the file with your Discord webhook URL and rerun the application.")
sys.exit(1)

region_mapping = {
".au": "Sydney",
".ap": "Singapore",
Expand Down
7 changes: 4 additions & 3 deletions bin_arc/ussr-ssl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# bin/ussr-ssl.py

import subprocess
import os
import requests
Expand All @@ -22,7 +24,7 @@

app = Flask(__name__)

MC_FOLDER = '.mc/'
MC_FOLDER = 'bin/.mc/'
DISCORD_WEBHOOK_URL_FILE = '../config/webhook.txt'

def get_discord_webhook_url():
Expand All @@ -46,8 +48,7 @@ def index():
@app.route('/start')
def start():
send_discord_message('``server starting...``')

start_command = ['java', '-jar', '-Xms256M', '-Xmx5G', f'{MC_FOLDER}/fabric.jar']
start_command = ['java', '-jar', '-Xms256M', '-Xmx5G', f'{MC_FOLDER}/server.jar']
subprocess.Popen(start_command, cwd=MC_FOLDER)

time.sleep(27)
Expand Down
57 changes: 25 additions & 32 deletions bin_win/script/ngroksenpai.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import subprocess
import requests
import json
Expand All @@ -7,7 +6,6 @@
import time

LOCK_FILE = "ngroksenpai.lock"
WEBHOOK_FILE_PATH = '../config/webhook.txt'

def check_lock_file():
return os.path.exists(LOCK_FILE)
Expand All @@ -27,40 +25,20 @@ def check_tunnel(curl_command, target_string):
return output
return None

# thx chatgpt lmao
def get_discord_webhook_url(file_path):
with open(file_path, 'r') as file:
return file.read().strip()

def send_discord_webhook(webhook_url, region, url):
message = f"* {region} === `{url}`"
payload = {"content": message}
requests.post(webhook_url, json=payload)

os.chdir('../config')
with open("conf.txt", "r") as conf_file:
conf_lines = conf_file.readlines()

use_ngrok = False
autongrok = False

for line in conf_lines:
if line.startswith("#"):
continue
parts = line.strip().split('=')
if len(parts) == 2:
key, value = parts[0].strip(), parts[1].strip()
if key == "use-ngrok" and value.lower() == "true":
use_ngrok = True
elif key == "autongrok" and value.lower() == "true":
autongrok = True

if autongrok:
starter_script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'starter.bat')
subprocess.Popen(['cmd', '/c', starter_script_path])


time.sleep(10)
def read_config(file_path):
config = {}
with open(file_path, 'r') as file:
lines = file.readlines()
for line in lines:
if '=' in line:
key, value = line.strip().split('=')
config[key.strip()] = value.strip()
return config

def main():
if check_lock_file():
Expand All @@ -70,7 +48,13 @@ def main():
create_lock_file()

try:
discord_webhook_url = get_discord_webhook_url(WEBHOOK_FILE_PATH)
config = read_config('../config/conf.txt')

if config.get('autongrok') == 'True':
starter_script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'starter.bat')
subprocess.Popen(['cmd', '/c', starter_script_path])
time.sleep(15)
print("WORKING")

curl_commands = [
"curl 127.0.0.1:4040/api/tunnels",
Expand All @@ -82,6 +66,15 @@ def main():

target_string = "tcp://"

webhook_file_path = '../config/webhook.txt'
if os.path.exists(webhook_file_path):
with open(webhook_file_path, 'r') as webhook_file:

discord_webhook_url = webhook_file.read().strip() # webhook func
else:
print("Error: webhook.txt not found. Please create the file with your Discord webhook URL and rerun the application.")
sys.exit(1)

region_mapping = {
".au": "Sydney",
".ap": "Singapore",
Expand Down
7 changes: 4 additions & 3 deletions bin_win/ussr-ssl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# bin/ussr-ssl.py

import subprocess
import os
import requests
Expand All @@ -22,7 +24,7 @@

app = Flask(__name__)

MC_FOLDER = '.mc/'
MC_FOLDER = 'bin/.mc/'
DISCORD_WEBHOOK_URL_FILE = '../config/webhook.txt'

def get_discord_webhook_url():
Expand All @@ -46,8 +48,7 @@ def index():
@app.route('/start')
def start():
send_discord_message('``server starting...``')

start_command = ['java', '-jar', '-Xms256M', '-Xmx5G', f'{MC_FOLDER}/fabric.jar']
start_command = ['java', '-jar', '-Xms256M', '-Xmx5G', f'{MC_FOLDER}/server.jar']
subprocess.Popen(start_command, cwd=MC_FOLDER)

time.sleep(27)
Expand Down
6 changes: 5 additions & 1 deletion scripts/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import platform
import webbrowser
import subprocess

def clear_screen():
system = platform.system().lower()
Expand Down Expand Up @@ -72,7 +73,10 @@ def ussr_for_arch():
else:
print("Only 'y' or 'n'. Indecisive enough?")

os.system('ngrok config add-authtoken {ngrok_token}')
with open('../config/token.txt', 'r') as file:
ngrok_token = file.read().strip()
os.system(f'ngrok config add-authtoken {ngrok_token}')

os.system('chmod +x start.sh')
os.system('./start.sh')
os.chdir('../scripts')
Expand Down

0 comments on commit 136ca62

Please sign in to comment.