Here’s a simple way to limit inbound adjacent connections using Event Management. This has had limited testing. Your feedback is welcome.
In your node stanza (ie [1999]) of rpt.conf add or uncomment events = events. Near the bottom of rpt.conf add or edit an events stanza. Change the 1 to your desired limit.
[events]
MAXLINKS = v|e|$[${RPT_NUMALINKS} >= 1] ; Test inbound links for GE n links
cop,49 = c|t|MAXLINKS ; Disable links if MAXLINKS goes true
cop,50 = c|f|MAXLINKS ; Enable links if MAXLINKS goes false
This is to look at incoming calling nodes to see if their connected to other nodes and permit the connection or deny the connection? Or does it allow the incoming node to connect, then disable incoming connections to prevent more nodes from connecting?
I’m looking for a solution to allow incoming nodes to connect that aren’t connected to other nodes.
Under the assumption that it only allows nodes to connect that aren’t connected to anyone else, I added this to the system and haven’t seen this to be true.
I added the events = events in the node stanza and added the [events] section to the bottom of rpt.conf, then reloaded.
The above demonstrated script only stops ‘all inbound connections’ when a limit of connections has been met. It does nothing to say which nodes. For that you will have to get more creative in the script to determine criteria you are seeking. Useful for bandwidth issues where to many connections will cause the system to crash.
I might cation you a bit for what you describe as more than half of the nodes out there have a connection to a local private node or a hub node and that can be much harder to determine if you wanted to allow them. So in effect, you may be limiting yourself unnecessarily to very few nodes allowed for connection.
To do what you ask would require that you query the incoming attempt to find out how many nodes they have connected to them, but you will be unable to determine what type of connection they are or the current activity level.
And I might add, the number of connections has nothing to do with activity level that it seems you are attempting to limit.
The later. When the current number of connections reach the limit, no more connections can occur as linking becomes disabled. And the reverse; when the current number of connections drops below the desired limit, incoming connections are enabled.
I’ve noticed a couple of the larger networks do allow a connect and then appear to examine the number of links and then disconnect if more than N connection.
If I were to code something like that I’d call a script with connpgm and then use the 3rd API shown here to find out how many links and then do an asterisk -rx "rpt cmd *myNode* ilink 13 *theirNode* or not depending the desired limit.