So... from /etc/config/wireguard Or /etc/config/wireguard/conf where the Server/Client files download?
Also do I use the file name of the conf-file as "pl-waw.prod.json"
EDIT: My bad!
My eyes are shot from tinkering with @patrickm script. I deleted so much from my run directory that I didn't see what was right in front of me.
His mangled/sniffed/ script dropped a lot of curl and used more jq and the output of the surf_servers.json file is replaced with surfshark_servers.json in the exact same format as your cat command. Much easier to read.. but what to I gain from examining this json file?
Brain Dump! Feel free to share a cool link because I'll read it.
Thanks again for stretching my limits.
Bill
Going out on the limb I frequent so often:
Could I assume that grooming the surfshark_servers.json/ surf_servers.json file to the list of server/peers I want, getting me a baby step closer, to then utilizing this in a elusively beautiful "simple uci script" for round-robin?
Thinking this as applied learning for a purpose of meeting a goal.
Depending how you set up your default route (all traffic via ‘wan’ or OpenVpn tunnel or WG or ???) VPN-PBR just lets you direct specific devices to be routed to other than your default route. Ergo, it doesn’t interact with VPN-PBR other than presenting an additional service gateway.
uci by itself will produce a cheat sheet for reference.
uci show network will show you /etc/config/network in UCI format. You want to concern yourself with the Peer 2 section for your WG interface. Two entries need to be revised server PubKey and your corresponding new endpoint host.
Script Pseudo code:
uci set PubKey
uci set Preferred Server endpoint
uci commit
/etc/init.d/network restart ; /etc/init.d/firewall restart
shows one of my four peer2 wireguard endpoints. Now I just have to learn how to reorder the list. hehehehehehhehehhe don't tell me!!
Thanks Paul!
I'll study the uci usage further. I currently have a working script, however, I purpose to understand the basics. I had manually entered into Luci, 3 additional peer2. Last entered endpoint becomes wireguard connection uponuci commit ; /etc/init.d/network restart ; /etc/init.d/firewall restart.
I did that early yesterday and have 4 scripts to initialize the "preferred peer2" but it's adds an additional redundant entry into /etc/config/network.
So with your guidance above I have some reading and honing to accomplish, as the pic below is........ blah ok....... your help has given me some more tools to explore.
I'm sure there exist eaiser methods, I for one could just drop a pre made "network" file into /etc/config/network and restart. But it was a fun challenge and I learned something. When the other options pop up; I'll learn more! Enjoy your journey. @RuralRoots I have the suggestion saved to learn along with jq curl cat Thank you.
#!/bin/sh
echo "Running at $(date)"
uci reorder network.@[13]=12
uci commit network
/etc/init.d/network restart
logger -t yourIFname ":$(date) connection established"
## Undo examples:
## uci reorder network.@[13]=12
## uci reorder network.@[12]=13
## uci reorder network.@[13]=11
## uci reorder network.@[11]=13
## uci reorder network.@[13]=10
## uci reorder network.@[10]=13
## uci reorder network.@[13]=9
## uci reorder network.@[9]=13
####################################################################################
# MULTIPLE PEER(2) NETWORKS CAN BE ADDED TO LUCI AND SWAPPED BY .sh
# These networks are known by the notations below. Goal is to find peer(2).
# Plug in a number, or examine your "network" file ~ vi , nano, gui ~
# Count the unique "config" entries to find your first and last peer(2) entry
#
# (uci show network.@[]) #example will show first top entry /etc/config/network
# (uci show network.@[0]) #example will also show first top entry /etc/config/network
# (uci show network.@[1]) #example will show second entry /etc/config/network
# (uci show network.@[2]) #example will show third entry /etc/config/netork
# ....
# (uci show network.@[13] #example ~~ 13th entry /etc/config/network
# last peer=wg0 current tunnel us-nyc!
######################### Visual ##############################
#root@Dachshund:~# uci show network.@[]
#network.loopback=interface
#network.loopback.ifname='lo'
#network.loopback.proto='static'
#network.loopback.ipaddr='127.0.0.1'
#network.loopback.netmask='255.0.0.0'
#root@Dachshund:~# uci show network.@[0]
#network.loopback=interface
#network.loopback.ifname='lo'
#network.loopback.proto='static'
#network.loopback.ipaddr='127.0.0.1'
#network.loopback.netmask='255.0.0.0'
#root@Dachshund:~# uci show network.@[1]
#network.globals=globals
#network.globals.ula_prefix='0:0:0:0::/0'
#root@Dachshund:~# uci show network.@[13]
#network.cfg0e6912=wireguard_SSWG
#network.cfg0e6912.public_key='rhuoCmHdyYrh0zW3J0YXZK4aN3It7DD26TXlACuWnwU='
#network.cfg0e6912.peersistent_keepalive='25'
#network.cfg0e6912.endpoint_port='51820'
#network.cfg0e6912.allowed_ips='0.0.0.0/0' '::/0'
#network.cfg0e6912.route_allowed_ips='1'
#network.cfg0e6912.endpoint_host='us-nyc.prod.surfshark.com'
#network.cfg0e6912.description='nyc-prod'
#
# Per OpenWrt - CFGID's are assigned to WireGuard Peers in order a~z.
# Shown below as cfg0(a)6912, cfg0(b)6912, etcetera
# Static entries insofar as peers do not move in order, unless commanded to. This sh's goal.
# The command: (uci reorder network.'cfg0a6912'=) will move that peer <NOTE:AVOID>
# to the very top of your /etc/config/network file and the CFGID's will change!
# The command: (uci reorder network.@[9]=) will move that peer <NOTE:AVOID>
# to the very top of your /etc/config/network file and the CFGID's will change!
# These CFGID can be found by either using a web browser's inspect tool
# upon the peer in the setup section of the Peer Tab in Luci, or
# invoking a save and then inspecting the "unsaved changes" section,
# or uci reorder network.@[#] where # represents number (see above [1]) of config line entry
# in your 'network' file, and then using (uci changes) to view the cfg0xxxxxx
# or using (uci show network.'cfgxxxxxx') if you happen to know xxxxxx
# Last entry will become path>wg0 tunnel. In this ex. cfg0e6912 is path.
# This example demonstrate five peers added via uci or Luci.
#
# cfg0a6912 #example cfg0a6912 is fr-bod
# cfg0b6912 #example cfg0a6912 is jp-tok
# cfg0c6912 #example cfg0a6912 is it-rom
# cfg0d6912 #example cfg0a6912 is pl-waw
# cfg0e6912 #example cfg0a6912 is us-nyc
#
# ***Issuing a reorder command to move from us-nyc onto pl-waw***
# Since us-nyc is the 13th config line [13] and currently cfg0e6912
# Since pl-waw is the 12th config line [12] and currently cfg0d6912
# uci the following...
#
#root@Dachshund:~# uci reorder network.@[13]=12
#root@Dachshund:~# uci changes
#network.cfg0e6912='12'
#uci: Entry not found
#uci: Entry not found
#uci: Entry not found
#uci: Entry not found
#uci: Entry not found
#root@Dachshund:~# uci export network
#package network
#
#config interface 'loopback'
# option ifname 'lo'
# option proto 'static'
# option ipaddr '127.0.0.1'
# option netmask '255.0.0.0'
#
#config globals 'globals'
# option ula_prefix '0:0:0:0::/0'
#
#### TRUNCATED ####
#
#config wireguard_SSWG
# option public_key 'rhuoCmHdyYrh0zW3J0YXZK4aN3It7DD26TXlACuWnwU='
# option peersistent_keepalive '25'
# option endpoint_port '51820'
# list allowed_ips '0.0.0.0/0'
# list allowed_ips '::/0'
# option route_allowed_ips '1'
# option endpoint_host 'us-nyc.prod.surfshark.com'
# option description 'nyc-prod'
#
#config wireguard_SSWG
# option public_key 'vBa3HK7QXietG64rHRLm085VMS2cAX2paeAaphB/SEU='
# option persistent_keepalive '25'
# option endpoint_port '51820'
# list allowed_ips '0.0.0.0/0'
# list allowed_ips '::/0'
# option route_allowed_ips '1'
# option endpoint_host 'pl-waw.prod.surfshark.com'
# option description 'waw-prod'
#
#root@Dachshund:~# uci commit ; /etc/init.d/network restart
#
# Now pl-waw takes the CFGID of cfg0e6912 and position of 13th and is VPN tun.
# Now us-nyc takes the CFGID of cfg0d6912 and position of 12th.
# Changes will be reflected in the Peer Tab of Setup and the WireGuard Status page.
###################################################################################
The thought process is that since we have an "Add Peer" button and the "Delete" button; if I could manipulate these commands from deleteConfiguration and uci.remove to say reorderConfiguration and uci.reorder and if it work then, move onto adding an addition line, and button. But it failed.
I threw several blind punches, at the line: rebooted the router.. the good news is I didn't brick luci. So any ideas Paul? Do you mingle with some top notch js peeps?
On somewhat of a sidetrack I found this odd: All these *.json dated files several week old. Which would match the time I started from scratch. Oddly no surfshark_servers.json files AKA from running @patrickm script.
I meddled around with his script and actually produced a copy and somehow manage to get the "handicapped" conf files place in my run /etc/config/wireguard/conf folder.
BUT..
find / -iname wg.json
So it's not odd to have these sticks scatter in the wind?
Sorry to resurrect an old post, but in case anyone else gets the HTTP 429 error / not allowed error from wg_check_pubkey(), I found the fix to this in the below SS article...
The bricking comment was pointed at manipulating the wireguard.js file.
The file contents of the various and multiple *.json files are exactly what one would expect ~ yet dated. Perhaps ~ and most likely ~ running the wg_gen_config.sh file in WinSCP from the /www/luci-static/* folders during testing populated the errantly located files. I'll delete!
Thread Master Bot suggested I consolidate: So..
Does your repo edition of the script add verbosity to flag 429 error like @patrickm script does?
Other than adding -v option to the curl responses to figure what HTTP Responses were being returned, No. Only encountered it when I initially used my .ovpnCredentials in config.json.
Dear Professor.. I had read this entire thread before joining, but your issue was the reason I joined. I hate to leave a rock unturned. I think this might help revive brain stem activity. Happy Regards!
This version is known to work on OpenWrt versions supporting GUI/LuCi implementations of drag/drop confs within the interface settings. * Tested working on OpenWrt 22.03.0-rc6.
Option switches implemented in the script w/descriptions and remarks.
Tweaked to overcome a newly seen error in the execution of function passing do_login to reg_pubkey .
Bug fixes to correct recalling some functions in vain.
Increased the downloadable 'client conf's'
Preconfigured to have one working peer in wg0 ; and firewall setting for wg0 set to zone WAN.
Rename the keys.sh to anything you like,, I don't prefer long names with underscores...etc.
If your are considering using this with a current install: Save your wg.json file before running keys.sh -d . keys.sh -d will only remove from /etc/config/network and /etc/config/firewall the what the keys.sh -n command implanted.
However, it will wipe the /wg/ directory of token.json , wg.json , surfshark_servers.json , and the /wg/conf/* directory.
Usage
Safe usage of keys.sh inline with a current install would be to run with option: "Generate Server conf" or "Extend Key Duration".
Those commands are considered standard option is sswg.sh.
reIyst Add files via upload "sswg2.sh"
…
Latest commit 894dea8 26 seconds ago
History
With the new "000" Failure in reg_pubkey and do_login...
we're calling out the "000" failure in curl...
continuing with generation of new/updated "Token.json"!
Logging in...
Overcoming Curl 000 failure...
HTTP status OK
This README is dedicated to making a cli uci install of the Wireguard services and sswg script to enable one to swap endpoint easily and quickly. The front end work is lengthy, mostly reading; yet the outcome is well worth the time, especially since most of the work of configuration is uci set. Enjoy!
Reboot your system so the above packages can manifest in Luci.
Installing w/out Peer(1) and with Multi Peer for uci cli Swapping.
Follow the Templet Use all or at least two, or configure within the file your own. Double check the wan.metric='10' with ip route show default to ensure metric 10 is not already in use; modify accordingly. All public key are dummy. Until changed with legitimate pub key from you downloaded client conf files; you will be without Internet access.
cd /
uci set network.wan.metric='10'
uci set network.wg0=interface
uci set network.wg0.proto='wireguard'
uci set network.wg0.listen_port='51820'
uci set network.wg0.addresses='10.14.0.2/8'
uci set network.wg0.private_key=$(eval echo $(jq '.prv' ./wg/wg.json))
uci commit network
uci set network.peerchiu='wireguard_wg0'
uci set network.peerchiu.description=peerchiu
uci set network.peerchiu.public_key=DpMfulanF/MVHmt3AX4dqLqcyE0dpPqYBjDlWMaUI00=
uci add_list network.peerchiu.allowed_ips='0.0.0.0/0'
uci add_list network.peerchiu.allowed_ips='::/0'
uci set network.peerchiu.route_allowed_ips='1'
uci set network.peerchiu.endpoint_host=us-chi.prod.surfshark.com
uci set network.peerchiu.endpoint_port='51820'
uci set network.peerchiu.persistent_keepalive='25'
uci commit network
uci set network.peerdalu='wireguard_wg0'
uci set network.peerdalu.description=peerdalu
uci set network.peerdalu.public_key=0iwHQpV+rsOg38ogv4g4XMLJa51YqWY/yKWR9UEUMDk=
uci add_list network.peerdalu.allowed_ips='0.0.0.0/0'
uci add_list network.peerdalu.allowed_ips='::/0'
uci set network.peerdalu.route_allowed_ips='1'
uci set network.peerdalu.endpoint_host=us-dal.prod.surfshark.com
uci set network.peerdalu.endpoint_port='51820'
uci set network.peerdalu.persistent_keepalive='25'
uci commit network
uci set network.peernycu='wireguard_wg0'
uci set network.peernycu.description=peernycu
uci set network.peernycu.public_key=rhuoCmHdyYrh0zW3J0YXZK4aN3It7DD26TXlACuWnwU=
uci add_list network.peernycu.allowed_ips='0.0.0.0/0'
uci add_list network.peernycu.allowed_ips='::/0'
uci set network.peernycu.route_allowed_ips='1'
uci set network.peernycu.endpoint_host=us-nyc.prod.surfshark.com
uci set network.peernycu.endpoint_port='51820'
uci set network.peernycu.persistent_keepalive='25'
uci commit network
uci set network.peerwarp='wireguard_wg0'
uci set network.peerwarp.description=peerwarp
uci set network.peerwarp.public_key=vBa3HK7QXietG64rHRLm085VMS2cAX2paeAaphB/SEU=
uci add_list network.peerwarp.allowed_ips='0.0.0.0/0'
uci add_list network.peerwarp.allowed_ips='::/0'
uci set network.peerwarp.route_allowed_ips='1'
uci set network.peerwarp.endpoint_host=pl-waw.prod.surfshark.com
uci set network.peerwarp.endpoint_port='51820'
uci set network.peerwarp.persistent_keepalive='25'
uci commit network
uci set network.peertorc='wireguard_wg0'
uci set network.peertorc.description=peertorc
uci set network.peertorc.public_key=W9bzkcL3fiV64vDpB4pbrz8QafNn3y5P9Yc/kQvy4TA=
uci add_list network.peertorc.allowed_ips='0.0.0.0/0'
uci add_list network.peertorc.allowed_ips='::/0'
uci set network.peertorc.route_allowed_ips='1'
uci set network.peertorc.endpoint_host=ca-tor.prod.surfshark.com
uci set network.peertorc.endpoint_port='51820'
uci set network.peertorc.persistent_keepalive='25'
uci commit network
/etc/init.d/network restart
To minimize Firewall setup; Consider VPN network as public. Assign VPN interface to WAN zone.
The peer swapping is achieved by placing the desired peer config in the last/bottom order of the /etc/config/network file. The high arbitrary number '99' should suffice to place desired network peer at bottom. My personal config has only 15. The resulting command will also be represented in the Wireguard Status, Interface Peer Pages of Luci. Simple command, long description.
From the above install, Toronto Canada is the last peer installed and will be the default route the wg0 vpn tunnels through. By running the below command the Warsaw Poland endpoint takes the bottom position and becomes wg0 vpn tunnel. This is achieved from the network.peerwarp NETWORK not the description=peerwarp! A look at your /etc/config/network file will enlighten your understanding later.
Q1 2022 Dates: January 1 - March 31 THE QUARTER IS OVER Q2 2022 Dates: April 1 - June 30 THE QUARTER IS OVER
Q3 2022 Dates: July 1 - September 30 KEEP HITTING THE SITE
Q4 2022 Dates: October 1 - December 31