MCPcopy Index your code
hub / github.com/masterking32/MasterHttpRelayVPN / configure_network

Function configure_network

setup.py:121–149  ·  view source on GitHub ↗
(cfg: dict)

Source from the content-addressed store, hash-verified

119
120
121def configure_network(cfg: dict) -> dict:
122 print()
123 print(bold("Network settings") + dim(" (press enter to accept defaults)"))
124 cfg["lan_sharing"] = prompt_yes_no(
125 "Enable LAN sharing?",
126 default=bool(cfg.get("lan_sharing", False)),
127 )
128
129 default_host = str(cfg.get("listen_host", "127.0.0.1"))
130 if cfg["lan_sharing"] and default_host == "127.0.0.1":
131 default_host = "0.0.0.0"
132 cfg["listen_host"] = prompt("Listen host", default=default_host)
133
134 port = prompt(
135 "HTTP proxy port",
136 default=str(cfg.get("http_port", cfg.get("listen_port", 8085))),
137 )
138 try:
139 cfg["http_port"] = int(port)
140 except ValueError:
141 cfg["http_port"] = 8085
142
143 # SOCKS5 is always enabled at runtime; only port is configurable.
144 sport = prompt("SOCKS5 port", default=str(cfg.get("socks5_port", 1080)))
145 try:
146 cfg["socks5_port"] = int(sport)
147 except ValueError:
148 cfg["socks5_port"] = 1080
149 return cfg
150
151
152def write_config(cfg: dict) -> None:

Callers 1

mainFunction · 0.85

Calls 5

boldFunction · 0.85
dimFunction · 0.85
prompt_yes_noFunction · 0.85
promptFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected