aboutsummaryrefslogtreecommitdiff
path: root/src/view/index.html
blob: 5374771bdf7778eecdc0782cee9256095ff169dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>WireGuard to Networkd Converter</title>
	<link
		href="/css/bootstrap.min.css"
		rel="stylesheet"
		integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
	>
	<script src="/js/bundle.min.js"></script>
	<script>
		let wg2nd_cmdseq = null;

		function convert_config() {
			// Get the values from the input elements
			const interfaceName = document.getElementById('interfaceName');
			const wireguardConfig = document.getElementById('wireguardConfig');

			console.log(wireguardConfig);

			// Call the wg2nd_cmdseq function
			const result = wg2nd_cmdseq(interfaceName.value, wireguardConfig.value);

			// Put the result in the third box (Systemd Networkd Configuration text area)
			const outputTextArea = document.getElementById('systemdConfigCmds');

			outputTextArea.value = result;
			outputTextArea.style.height = 'auto';
			outputTextArea.style.height = outputTextArea.scrollHeight + 'px';
		}

		var Module = {
			onRuntimeInitialized: function() {
				wg2nd_cmdseq = Module.wg2nd_cmdseq;

				convert_config();
			}
		};


		window.addEventListener('load', function () {
			// Attach event listeners
			document.getElementById('genConfig').addEventListener('click', (e) => {
				convert_config();
			});
		});


	</script>
	<script src="/build/browser.js"></script>
</head>
<body>
	<div class="container mt-4 font-monospace">
		<!-- Title -->
		<div class="row mb-4 bg-light p-4 rounded">
			<h1 class="mb-4">wg2nd</h1>
			<h3 class="mb-4">Configure WireGuard Tunnels with networkd</h3>
			<p>wg2nd converts WireGuard configurations from wg-quick format into systemd-networkd compatible configurations.
			This is a web port of wg2nd which converts WireGuard configurations into Bash commands to set up the networkd
			device and network. Note that the output is not compatible with Zsh. <strong>The web port operates entirely on the client-side,
			ensuring that no sensitive data is transmitted or stored externally.</strong> For more comprehensive control and features,
		including batch conversions and the option to install a firewall, the Linux tool wg2nd is available <a href="https://www.git.flu0r1ne.net/wg2nd">here</a> and can
			be installed from source.</p>

			<p>Both versions are open-source and dual-licensed under the GPL-2.0 and MIT license. Limitations and further details for each version
			are elaborated in this <a href="https://www.flu0r1ne.net/logs/announcing-wg2nd">comprehensive post</a>. For installation instructions for the Linux tool and additional information,
			please refer to the <a href="https://www.git.flu0r1ne.net/wg2nd/tree/README.md?h=main">README</a>.</p>
		</div>

		<!-- Input Panel -->
		<div class="row bg-light p-4 rounded">
			<h5 class="mb-4">WireGuard Configuration</h5>
			<div class="mb-3">
				<label for="interfaceName" class="form-label">Interface Name:</label>
				<input autocomplete="off" type="text" class="form-control" id="interfaceName" value="wg0" />
			</div>
			
			<div class="mb-3">
				<label for="wireguardConfig" class="form-label">WireGuard Config:</label>
				<textarea
					autocomplete="off"
					autocorrect="off"
					autocapitalize="off"
					spellcheck="false"
					id="wireguardConfig"
					class="form-control"
					rows="12"
				>
[Interface]
PrivateKey = 0OCS+dV5wsDje6qUAEDQzPmTNWOLE9HE8kfGU1wJUE0=
Address = 10.55.127.342/32, ab00:aaaa:aaa:aa02::5:abcd/128
DNS = 10.64.0.1

[Peer]
PublicKey = WBSnuq6Vswxz5G5zz9pUt60ZSA+JfZ1iTXdg0RJGjks=
AllowedIPs = 0.0.0.0/0,::0/0
Endpoint = 128.45.210.64:51821
				</textarea>
			</div>

			<!-- Convert Button -->
			<div class="d-grid text-center mt-2">
				<button id="genConfig" class="btn btn-primary">Generate Commands</button>
			</div>
		</div>

		<!-- Output Panel -->
		<div class="row mt-4 bg-light p-4 rounded">
			<h5 class="mb-4">Networkd Configuration</h5>
			<textarea
				id="systemdConfigCmds"
				class="form-control fs-6"
				placeholder="Converted configuration will appear here..."
				autocomplete="off"
				readonly
			></textarea>
		</div>
	</div>
</body>