Set Relay Server 1 and 2 Dynamically

Here is my current fixlet for setting my leaf relay servers settings (well one of them)

// Set advertisement list to location of Relay Server
setting "_BESRelay_Register_Affiliation_AdvertisementList"="{value of setting "location" of client}" on "{now}" for client

// Clears the seeklist setting
setting "_BESClient_Register_Affiliation_SeekList"="" on "{now}" for client

// Set manual relay selection
setting "__RelaySelect_Automatic"="0" on "{now}" for client

//Set Relay Properties


//set relay to top level relay
setting "__RelayServer1"="http://serverx:52311/bfmirror/downloads/" on "{now}" for client
setting "__RelayServer2"="http://servery:52311/bfmirror/downloads/" on "{now}" for client

I’d like to be able to change the setting of RelayServer1 and RelayServer2 to a random server (of which there are 4) that has the property _BESRelay_Register_Affiliation_AdvertisementList=“TIER1”

I think I’m mixing client and session relevance here which might cause it to not work the way I plan but ultimately I have 4 “TIER1” relays and I need it to pick one of those 4 to set the properties so any other way to do this would be great.

I had considered properties then choosing a random property but I got stuck writing that :smiley:

Why not just set an affiliation seeklist to TIER1 and set it for automatic select (with FailoverRelayList as well in case auto-select doesn’t work out)?

(Otherwise, no client knows the properties held by another, you can’t tell which relays are TIER1; you can randomize among a list, but you have to provide the list of four relays manually)

This should get a different relay name each time

q: tuple string items (random integer of number of tuple string items of it - 1) of ("relay1, relay2, relay3, relay4")
A: relay2
T: 0.092 ms
I: plural string

edit: get the list length dynamically

1 Like

Slight modification (untested) - would this work rather than setting seeklists?

parameter "t1relay1" = "{tuple string items (random integer of number of tuple string items of it - 1) of ("server1, server2")}"
parameter "t1relay2" = "{tuple string items (random integer of number of tuple string items of it - 1) of ("server3, server4")}"

// setting AdvertisementList value
setting "_BESRelay_Register_Affiliation_AdvertisementList"="{value of setting "location" of client}" on "{now}" for client

// clear seeklist setting
setting "_BESClient_Register_Affiliation_SeekList"="" on "{now}" for client

// set to manual relay selection
setting "__RelaySelect_Automatic"="0" on "{now}" for client

//set relay to top level relay
setting "__RelayServer1"="http://{parameter "t1relay"}.blah.com:52311/bfmirror/downloads/" on "{now}" for client
setting "__RelayServer2"="http://{parameter "t1relay2"}.blah.com:52311/bfmirror/downloads/" on "{now}" for client