# ---------------------------------------------------------
# MEMBERS

{{ "pre-clients"|include_local_file -}}

group "clients" {
{% for client in clients|sort(attribute="id") if client.ip is current_ipver %}

{%	if "rtt" in client and client["rtt"] %}
	# RTT: {{ client["rtt"] }} ms (normalized value: {{ client["rtt"]|get_normalized_rtt }})
{%	endif %}
	neighbor {{ client.ip }} {
		{{ "client"|include_local_file -}}
		remote-as {{ client.asn }}

{%	if "6.1"|target_version_le %}
		softreconfig in yes
{%	endif %}
{%	if client.description %}
		descr "{{ client.description|replace("\"", "")|truncate(31, true, "...", 0) }}"
{%	endif %}
{%	if client.cfg.passive %}
		passive
{%	endif %}
{%	if client.cfg.multihop %}
		multihop {{ client.cfg.multihop }}
{%	endif %}
{%	if client.password %}
		tcp md5sig password "{{ client.password }}"
{%	endif %}
{%	if client.cfg.gtsm %}
		ttl-security yes
{%	else %}
		ttl-security no
{%	endif %}
{%	if client.cfg.filtering.max_prefix.action == "shutdown" or
	   client.cfg.filtering.max_prefix.action == "restart" %}
{%      	if client.ip|ipaddr_ver == 4 and client.cfg.filtering.max_prefix.limit_ipv4 %}
{%              	set max_pref_limit = client.cfg.filtering.max_prefix.limit_ipv4 %}
{%      	elif client.ip|ipaddr_ver == 6 and client.cfg.filtering.max_prefix.limit_ipv6 %}
{%              	set max_pref_limit = client.cfg.filtering.max_prefix.limit_ipv6 %}
{%      	else %}
{%              	set max_pref_limit = 0 %}
{%      	endif %}
{%      	if max_pref_limit > 0 %}
{%			if client.cfg.filtering.max_prefix.action == "restart" %}
		max-prefix {{ max_pref_limit }} restart {{ client.cfg.filtering.max_prefix.restart_after }}
{%			else %}
		max-prefix {{ max_pref_limit }}
{%			endif %}
{%		endif %}
{%	endif %}
{%	if client.cfg.prepend_rs_as %}
		transparent-as no
{%	else %}
		transparent-as yes
{%	endif %}
		enforce neighbor-as no

{% if "6.3"|target_version_le %}
		announce all
{% endif %}
		announce as-4byte yes
{%	if client.ip|ipaddr_ver == 4 %}
		announce IPv6 none
		announce IPv4 unicast
{%	else %}
		announce IPv6 unicast
		announce IPv4 none
{%	endif %}

		set nexthop no-modify
	}
{% endfor %}
}

{{ "post-clients"|include_local_file -}}

