diff options
author | Trumeet <17158086+Trumeet@users.noreply.github.com> | 2021-01-20 17:43:38 -0800 |
---|---|---|
committer | Trumeet <17158086+Trumeet@users.noreply.github.com> | 2021-01-20 17:43:38 -0800 |
commit | 743ce8116634ccdce6dccec83571bcbdcfce1eb2 (patch) | |
tree | 8e6ef9420292ccb8b363e76e5ff151369a6079e5 | |
parent | b21a11e611ee440b9cb572dbe5cd2239bf1d1773 (diff) | |
download | dn42peering-743ce8116634ccdce6dccec83571bcbdcfce1eb2.tar dn42peering-743ce8116634ccdce6dccec83571bcbdcfce1eb2.tar.gz dn42peering-743ce8116634ccdce6dccec83571bcbdcfce1eb2.tar.bz2 dn42peering-743ce8116634ccdce6dccec83571bcbdcfce1eb2.zip |
feat(central): provide an example configurationv1.5
-rw-r--r-- | central/src/main/java/moe/yuuta/dn42peering/manage/ManageHandler.java | 8 | ||||
-rw-r--r-- | central/src/main/resources/manage/showconf.ftlh | 50 |
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><Custom Name></b>.conf + <#if !mpbgp> + protocol bgp dn42_<b><Custom Name></b> from dnpeers { + neighbor ${ipv4} as ${asn}; + direct; + } + </#if> + <#if peer_ipv6??> + protocol bgp dn42_<b><Custom Name></b>_v6 from dnpeers { + neighbor ${ipv6}<#if peer_link_local><b>%<Your WireGuard interface name></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><Your WireGuard Private Key></b>.conf + [Interface] + <#if peer_wg_listen_port??> + ListenPort = ${peer_wg_listen_port?long?c} + </#if> + PrivateKey = <b><Your WireGuard Private Key></b> + PostUp = ip addr add dev <b><Your WireGuard interface name></b>; ${peer_ipv4}/32 peer ${ipv4}/32 + <#if peer_ipv6??> + <#if peer_link_local> + PostUp = ip addr add dev <b><Your WireGuard interface name></b>; ${peer_ipv6}/64 + <#else> + PostUp = ip addr add dev <b><Your WireGuard interface name></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><Your WireGuard interface name></b>.</p> <a href="/manage">Back</a> </body> </html>
\ No newline at end of file |