 3314030d57
			
		
	
	
		3314030d57
		
	
	
	
	
		
			
			This reverts commit e5203543a674453ce1e0cbbcb234d3308762fe65. As swanky as it is to have a really short file, it's hard to justify and makes me nervous. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
		
			
				
	
	
		
			55 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="curve25519_generate.js" onError='document.write("<h3>Did you forget to run \"make\" to compile curve25519_generate.js?</h3><!--");'></script>
 | |
| <script>
 | |
| /* SPDX-License-Identifier: GPL-2.0
 | |
|  *
 | |
|  * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
 | |
|  */
 | |
| 
 | |
| function sendPubkeyToServer(pubkey, username, password)
 | |
| {
 | |
| 	alert("Sending " + username + ":" + password + " to server for new pubkey " + pubkey + "...");
 | |
| 
 | |
| 	// send info to server
 | |
| 
 | |
| 	var serverResponse = {
 | |
| 		publicKey: "6spHEFoJrp9pijbxjJoS6fHjZaAWQqtdFFO/OtpVe3w=",
 | |
| 		allowedIPs: [ "0.0.0.0/0", "::/0" ],
 | |
| 		endpoint: "demo.wireguard.com:63321",
 | |
| 		address: [ "192.168.18.42/32", "fd08:1234:1111::77/128" ],
 | |
| 		dns: [ "8.8.8.8", "8.8.4.4" ]
 | |
| 	}
 | |
| 
 | |
| 	return serverResponse;
 | |
| }
 | |
| 
 | |
| function downloadNewConfiguration()
 | |
| {
 | |
| 	var keypair = WireGuard.generateKeypair();
 | |
| 	var serverResponse = sendPubkeyToServer(keypair.publicKey, "zx2c4", "supersecretpassword");
 | |
| 
 | |
| 	var config = [];
 | |
| 	config.push("[Interface]");
 | |
| 	config.push("PrivateKey = " + keypair.privateKey);
 | |
| 	config.push("Address = " + serverResponse.address.join(", "));
 | |
| 	config.push("DNS = " + serverResponse.dns.join(", "));
 | |
| 	config.push("");
 | |
| 	config.push("[Peer]");
 | |
| 	config.push("PublicKey = " + serverResponse.publicKey);
 | |
| 	config.push("AllowedIPs = " + serverResponse.allowedIPs.join(", "));
 | |
| 	config.push("Endpoint = " + serverResponse.endpoint);
 | |
| 	config.push("");
 | |
| 	config = config.join("\n");
 | |
| 
 | |
| 	var blob = new Blob([config], { type: "text/plain" });
 | |
| 	var a = document.createElement("a");
 | |
| 	a.download = "demo0.conf";
 | |
| 	a.href = URL.createObjectURL(blob);
 | |
| 	a.style.display = "none";
 | |
| 	document.body.appendChild(a);
 | |
| 	a.click();
 | |
| 	document.body.removeChild(a);
 | |
| }
 | |
| </script>
 | |
| 
 | |
| <a href="javascript:downloadNewConfiguration()">Download a WireGuard configuration file</a>
 |