update tunnelier again
This commit is contained in:
@@ -23,6 +23,6 @@ setup(
|
||||
]
|
||||
},
|
||||
install_requires=[
|
||||
"psutil",
|
||||
"psutil", "pyyaml"
|
||||
],
|
||||
)
|
||||
|
||||
@@ -9,32 +9,33 @@ import sys
|
||||
from argparse import ArgumentError, ArgumentParser
|
||||
|
||||
import psutil
|
||||
import yaml
|
||||
|
||||
__version__ = "2024.01.07"
|
||||
__version__ = "2024.03.02"
|
||||
|
||||
CONFDIR = os.path.expanduser("~/.config/ssh-tunnelier")
|
||||
CONF = os.path.join(CONFDIR, "tunnels.json")
|
||||
CONF_OLD = os.path.join(CONFDIR, "tunnels.json")
|
||||
CONF = os.path.join(CONFDIR, "tunnels.yaml")
|
||||
# Just over a year in minutes
|
||||
MAGIC_TIME = 525601
|
||||
LOCALHOSTSYMBOL = "💻"
|
||||
|
||||
EXAMPLE_CONFIG = """{
|
||||
EXAMPLE_CONFIG = {
|
||||
"test": {
|
||||
"host": "host to connect, or defaults to name",
|
||||
"options": "-4 and other ssh options",
|
||||
"auto-connect": false,
|
||||
"auto-connect": False,
|
||||
"tunnels": [
|
||||
{
|
||||
"local_port": 1111,
|
||||
"remote_port": 8080,
|
||||
"remote_address": "localhost",
|
||||
"reverse": false,
|
||||
"comment": "`comment`, `reverse` and `remote_address` are not required"
|
||||
"reverse": False,
|
||||
"comment": "`comment`, `reverse` and `remote_address` are not required",
|
||||
}
|
||||
]
|
||||
],
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def args():
|
||||
@@ -106,11 +107,17 @@ def load_config():
|
||||
try:
|
||||
os.makedirs(CONFDIR, exist_ok=True)
|
||||
if not os.path.exists(CONF):
|
||||
if os.path.exists(CONF_OLD):
|
||||
with open(CONF_OLD, "r") as fp:
|
||||
config = json.load(fp)
|
||||
with open(CONF, "w") as fp:
|
||||
yaml.dump(config, fp, sort_keys=False)
|
||||
else:
|
||||
print("Creating example config: " + CONF)
|
||||
with open(CONF, "w") as fp:
|
||||
fp.write(EXAMPLE_CONFIG)
|
||||
yaml.dump(EXAMPLE_CONFIG, fp)
|
||||
with open(CONF, "r") as fp:
|
||||
config = json.load(fp)
|
||||
config = yaml.safe_load(fp)
|
||||
|
||||
for name in config:
|
||||
config[name]["host"] = config[name].get("host", name)
|
||||
|
||||
Reference in New Issue
Block a user