Skip to content

Commit

Permalink
fix WireGuard for 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Toperlock committed Dec 8, 2024
1 parent 3bd372e commit ad51a7d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions parsers/wg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ def parse(data):
'tag': unquote(server_info.fragment) or tool.genName()+'_wireguard',
'type': 'wireguard',
'private_key': netquery.get('privateKey') or unquote(server_info.netloc.rsplit("@", 1)[0]),
'peers': []
}
node['peers'] = {
peer_info = {
'address': re.sub(r"\[|\]", "", server_info.netloc.rsplit("@", 1)[-1].rsplit(":", 1)[0]),
'port': int(server_info.netloc.rsplit("@", 1)[-1].rsplit(":", 1)[1]),
'public_key': netquery.get('publicKey') or netquery.get('publickey'),
Expand All @@ -21,11 +22,12 @@ def parse(data):
],
'persistent_keepalive_interval': 30
}
node['peers'].append(peer_info)
if netquery.get('mtu'):
node['mtu'] = int(netquery['mtu'])
if netquery.get('reserved'):
reserved_value = netquery.get('reserved')
node['peers']['reserved'] = [int(val) for val in reserved_value.split(",")] if ',' in reserved_value else reserved_value
node['peers'][0]['reserved'] = [int(val) for val in reserved_value.split(",")] if ',' in reserved_value else reserved_value
ip_value = netquery.get('ip') or netquery.get('address')
if ',' in ip_value:
ipv4_value, ipv6_value = ip_value.split(",", 1)
Expand All @@ -36,5 +38,5 @@ def parse(data):
ipv4_value = ip_value + "/32" if '/' not in ip_value else ip_value
node['address'] = [ipv4_value]
if netquery.get('presharedKey'):
node['peers']['pre_shared_key'] = netquery['presharedKey']
node['peers'][0]['pre_shared_key'] = netquery['presharedKey']
return (node)

0 comments on commit ad51a7d

Please sign in to comment.