# Define settings for interfaces
:local interfaceConfigs {
{"P_NEW_WG_3_NS2"; 52821; "2"; "interfacekey1"; "TX100"; "10.3.0.0"; "10.3.0.2"; "TX100"; "ip1"; "10.3.0.1"; "10.7.0.1"; "peerkey1"};
{"P_NEW_WG_4_NS0"; 52822; "0"; "interfacekey2"; "CA200"; "10.4.0.0"; "10.4.0.2"; "CA200"; "ip2"; "10.4.0.1"; "10.3.0.1"; "peerkey2"};
{"P_NEW_WG_5_NS1"; 52823; "1"; "interfacekey3"; "GA100"; "10.5.0.0"; "10.5.0.2"; "GA100"; "ip3"; "10.5.0.1"; "10.6.0.1"; "peerkey3"};
{"P_NEW_WG_6_NS1"; 52824; "1"; "interfacekey4"; "NY600"; "10.6.0.0"; "10.6.0.2"; "NY600"; "ip4"; "10.6.0.1"; "10.5.0.1"; "peerkey4"};
{"P_NEW_WG_7_NS2"; 52825; "2"; "interfacekey5"; "CO261"; "10.7.0.0"; "10.7.0.2"; "CO261"; "ip5"; "10.7.0.1"; "10.4.0.1"; "peerkey5"}
}
:local networkprefix "/30"
:local protonid "PROTON"
# Remove existing configurations with the same comment
/interface wireguard remove [find comment~"^$protonid"]
/ip address remove [find comment~"^$protonid"]
/ip firewall mangle remove [find comment~"^$protonid"]
/ip route remove [find comment~"^$protonid"]
/ip dhcp-server network remove [find comment~"^$protonid"]
/interface wireguard peers remove [find comment~"^$protonid"]
/interface list member remove [find comment~"^$protonid"]
/routing rule remove [find comment~"^$protonid"]
# Loop through interface configurations
:local count [len $interfaceConfigs]
:for i from=0 to=($count - 1) do={
:local config $interfaceConfigs->[$i]
:local currentInterfaceName [:pick $config 0]
:local currentListenPort [:pick $config 1]
:local currentNetshieldValue [:pick $config 2]
:local currentPrivateKey [:pick $config 3]
:local currentServer [:pick $config 4]
:local currentNetworkID [:pick $config 5]
:local currentInterfaceAddress [:pick $config 6]
:local currentPeerServer [:pick $config 7]
:local currentEndpoint [:pick $config 8]
:local currentGateway [:pick $$config 9]
:local currentReversedGateway [:pick $$config 10]
:local currentPublicKey [:pick $config 11]
# Add WireGuard interface
/interface wireguard add comment=("$protonid " . $currentNetworkID . " Netshield " . $currentNetshieldValue . " " . $currentServer) listen-port=$currentListenPort mtu=1420 \
name=$currentInterfaceName private-key=$currentPrivateKey
# Add IP address for the interface
/ip address add address=($currentInterfaceAddress . $networkprefix) comment=$protonid interface=$currentInterfaceName network=$currentNetworkID
# Add mangle rule
/ip firewall mangle add action=change-mss chain=forward comment=$protonid new-mss=1360 \
out-interface=$currentInterfaceName passthrough=yes protocol=tcp tcp-flags=syn \
tcp-mss=!0-1375
# Add route proto_combo routing table with distance based on index
/ip route add check-gateway=ping dst-address=0.0.0.0/0 gateway=$currentGateway distance=($i + 1) comment=("$protonid Combo Route for " . $currentGateway . " Distance " . ($i + 1)) routing-table=proton_combo
# Add route to the proton_combo_reversed routing table with distance based on index
/ip route add check-gateway=ping dst-address=0.0.0.0/0 gateway=$currentReversedGateway distance=($i + 1) comment=("$protonid Combo Reversed Route for " . $currentReversedGateway . " Distance " . ($i + 1)) routing-table=proton_combo_reversed
# Add DHCP server network
/ip dhcp-server network add address=($currentNetworkID . $networkprefix) comment=("$protonid Network for " . $currentNetworkID) dns-server=$currentGateway gateway=$currentInterfaceAddress
# Add WireGuard peers
/interface wireguard peers add interface=$currentInterfaceName public-key=$currentPublicKey allowed-address=0.0.0.0/0 endpoint-address=$currentEndpoint name=$currentPeerServer endpoint-port=51820 persistent-keepalive=25s \
comment=("$protonid Peer " . $currentPeerServer)
# Add WAN members
/interface list member add comment=$protonid interface=$currentInterfaceName list=WAN
# Add routing rules
/routing rule add action=lookup-only-in-table table=main src-address=0.0.0.0/0 dst-address=($currentNetworkID . $networkprefix) place-before=4 comment=("$protonid Routing Rule for " . $currentNetworkID)
}
there seems to be syntax issue here. :local config $interfaceConfigs->[$i] . can someone help? manual mentions this as the way to access 2D Arrays