aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrumeet <17158086+Trumeet@users.noreply.github.com>2021-01-20 17:43:38 -0800
committerTrumeet <17158086+Trumeet@users.noreply.github.com>2021-01-20 17:43:38 -0800
commit743ce8116634ccdce6dccec83571bcbdcfce1eb2 (patch)
tree8e6ef9420292ccb8b363e76e5ff151369a6079e5
parentb21a11e611ee440b9cb572dbe5cd2239bf1d1773 (diff)
downloaddn42peering-1.5.tar
dn42peering-1.5.tar.gz
dn42peering-1.5.tar.bz2
dn42peering-1.5.zip
feat(central): provide an example configurationv1.5
-rw-r--r--central/src/main/java/moe/yuuta/dn42peering/manage/ManageHandler.java8
-rw-r--r--central/src/main/resources/manage/showconf.ftlh50
2 files changed, 58 insertions, 0 deletions
diff --git a/central/src/main/java/moe/yuuta/dn42peering/manage/ManageHandler.java b/central/src/main/java/moe/yuuta/dn42peering/manage/ManageHandler.java
index db856ff..8785a69 100644
--- a/central/src/main/java/moe/yuuta/dn42peering/manage/ManageHandler.java
+++ b/central/src/main/java/moe/yuuta/dn42peering/manage/ManageHandler.java
@@ -911,6 +911,12 @@ public class ManageHandler implements ISubRouter {
root.put("wgPresharedSecret", peer.getWgPresharedSecret());
root.put("wgSelfPubkey", peer.getWgSelfPubkey());
root.put("mpbgp", peer.isMpbgp());
+ root.put("peer_type", peer.getType());
+ root.put("peer_ipv4", peer.getIpv4());
+ root.put("peer_ipv6", peer.getIpv6());
+ if(peer.getWgEndpoint() != null) {
+ root.put("peer_wg_listen_port", peer.getWgEndpointPort());
+ }
if(node == null) {
root.put("ipv4", "This node is currently down! Edit the peer to choose another one.");
@@ -922,8 +928,10 @@ public class ManageHandler implements ISubRouter {
try {
if(peer.isIPv6LinkLocal()) {
root.put("ipv6", node.getDn42Ip6());
+ root.put("peer_link_local", true);
} else {
root.put("ipv6", node.getDn42Ip6NonLL());
+ root.put("peer_link_local", false);
}
} catch (IOException e) {
return Future.failedFuture(e);
diff --git a/central/src/main/resources/manage/showconf.ftlh b/central/src/main/resources/manage/showconf.ftlh
index 5c5f24d..a93e7cc 100644
--- a/central/src/main/resources/manage/showconf.ftlh
+++ b/central/src/main/resources/manage/showconf.ftlh
@@ -16,6 +16,56 @@
<li>WireGuard Preshared Secret: ${wgPresharedSecret}</li>
<li>MP-BGP: ${mpbgp?string('Yes', 'No')}</li>
</ul>
+<h2>Example Configuration</h2>
+<p>Notice: The following configuration is for newcomers or referencing purposes only.
+ You should always check and modify them according to your environment.
+<b>Bold parts are placeholders and you should customize them.</b></p>
+<h3>BIRD2 Configuration</h3>
+<p>You first need to setup your BIRD2 by following <a href="https://wiki.dn42.us/howto/Bird2">dn42 Wiki</a>.</p>
+<pre>
+ # /etc/bird/peers/<b>&lt;Custom Name&gt;</b>.conf
+ <#if !mpbgp>
+ protocol bgp dn42_<b>&lt;Custom Name&gt;</b> from dnpeers {
+ neighbor ${ipv4} as ${asn};
+ direct;
+ }
+ </#if>
+ <#if peer_ipv6??>
+ protocol bgp dn42_<b>&lt;Custom Name&gt;</b>_v6 from dnpeers {
+ neighbor ${ipv6}<#if peer_link_local><b>%&lt;Your WireGuard interface name&gt</b>;</#if> as ${asn};
+ direct;
+ }
+ </#if>
+</pre>
+<#if peer_type == "WIREGUARD">
+<h3>WireGuard Configuration</h3>
+<p>Choose ONE of the follow method.</p>
+<h4>wg-quick</h4>
+<pre>
+ # /etc/wireguard/<b>&lt;Your WireGuard Private Key&gt;</b>.conf
+ [Interface]
+ <#if peer_wg_listen_port??>
+ ListenPort = ${peer_wg_listen_port?long?c}
+ </#if>
+ PrivateKey = <b>&lt;Your WireGuard Private Key&gt;</b>
+ PostUp = ip addr add dev <b>&lt;Your WireGuard interface name&gt</b>; ${peer_ipv4}/32 peer ${ipv4}/32
+ <#if peer_ipv6??>
+ <#if peer_link_local>
+ PostUp = ip addr add dev <b>&lt;Your WireGuard interface name&gt</b>; ${peer_ipv6}/64
+ <#else>
+ PostUp = ip addr add dev <b>&lt;Your WireGuard interface name&gt</b>; ${peer_ipv6}/64 peer ${ipv6}/64
+ </#if>
+ </#if>
+ Table = off
+
+ [Peer]
+ PublicKey = ${wgSelfPubkey}
+ PresharedKey = ${wgPresharedSecret}
+ Endpoint = ${endpoint}:${wgPort}
+ AllowedIPs = 0.0.0.0/0, ::/0
+</pre>
+</#if>
+<p>Then, enable and start wg-quick service. For systemd users, you may want to use systemctl enable --now wg-quick@<b>&lt;Your WireGuard interface name&gt</b>.</p>
<a href="/manage">Back</a>
</body>
</html> \ No newline at end of file