Skip to content

Commit

Permalink
[change] Updated WireGaurd schema to use string type for endpoint_port
Browse files Browse the repository at this point in the history
Using integer type for endpoint_port field does not allow using variables
which is required for automatic template generation.
  • Loading branch information
pandafy committed Jun 28, 2021
1 parent 5385d72 commit 1b0d928
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/source/backends/openwrt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@ The following *configuration dictionary*:
"public_key": "94a+MnZSdzHCzOy5y2K+0+Xe7lQzaa4v7lEiBZ7elVE=",
"allowed_ips": ["10.0.0.1/32"],
"endpoint_host": "wireguard.test.com",
"endpoint_port": 51820,
"endpoint_port": "51820",
"preshared_key": "",
"persistent_keepalive": 60,
"route_allowed_ips": True,
Expand Down Expand Up @@ -2525,7 +2525,7 @@ The following *configuration dictionary*:
"public_key": "94a+MnZSdzHCzOy5y2K+0+Xe7lQzaa4v7lEiBZ7elVE=",
"allowed_ips": ["10.0.0.1/32"],
"endpoint_host": "wireguard.test.com",
"endpoint_port": 51820,
"endpoint_port": "51820",
"preshared_key": "",
"persistent_keepalive": 60,
"route_allowed_ips": True,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/backends/wireguard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ See an example of initialization and rendering below:
"allowed_ips": "10.0.0.4/32",
"preshared_key": "xisFXck9KfEZga4hlkproH6+86S8ki1tmLtMtqVipjg=",
"endpoint_host": "192.168.1.35",
"endpoint_port": 4908,
"endpoint_port": "4908",
},
],
}
Expand Down
7 changes: 2 additions & 5 deletions netjsonconfig/backends/wireguard/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,12 @@
},
"endpoint_port": {
"title": "endpoint port",
"type": "integer",
"description": (
"Wireguard port. Will be ignored if "
"\"endpoint host\" is left empty."
),
"default": 51820,
"maximum": 65535,
"minimum": 1,
"propertyOrder": 4,
"type": "string",
"pattern": "^[0-9]*$",
},
"preshared_key": {
"title": "pre-shared key",
Expand Down
4 changes: 2 additions & 2 deletions netjsonconfig/backends/wireguard/wireguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def auto_client(cls, host='', public_key='', server={}, port=51820, **kwargs):
},
'server': {
'public_key': public_key,
'endpoint_host': host,
'endpoint_port': server.get('port', 51820),
'endpoint_host': kwargs.get('vpn_host', host),
'endpoint_port': kwargs.get('vpn_port', server.get('port', 51820)),
'allowed_ips': [kwargs.get('server_ip_network', '')],
},
}

0 comments on commit 1b0d928

Please sign in to comment.