|
| 1 | +""" |
| 2 | +Wireguard specific JSON-Schema definition |
| 3 | +""" |
| 4 | +from copy import deepcopy |
| 5 | + |
| 6 | +from ...schema import schema as default_schema |
| 7 | + |
| 8 | +base_wireguard_schema = { |
| 9 | + "$schema": "http://json-schema.org/draft-04/schema#", |
| 10 | + "type": "object", |
| 11 | + "additionalProperties": True, |
| 12 | + "properties": { |
| 13 | + "wireguard": { |
| 14 | + "type": "array", |
| 15 | + "title": "Wireguard", |
| 16 | + "uniqueItems": True, |
| 17 | + "additionalItems": True, |
| 18 | + "propertyOrder": 12, |
| 19 | + "items": { |
| 20 | + "type": "object", |
| 21 | + "title": "Wireguard tunnel", |
| 22 | + "additionalProperties": True, |
| 23 | + "required": ["name", "port", "private_key"], |
| 24 | + "properties": { |
| 25 | + "name": { |
| 26 | + "title": "interface name", |
| 27 | + "description": "Wireguard interface name", |
| 28 | + "type": "string", |
| 29 | + "minLength": 2, |
| 30 | + "maxLength": 15, |
| 31 | + "pattern": "^[^\\s]*$", |
| 32 | + "propertyOrder": 1, |
| 33 | + }, |
| 34 | + "port": { |
| 35 | + "title": "port", |
| 36 | + "type": "integer", |
| 37 | + "default": 51820, |
| 38 | + "maximum": 65535, |
| 39 | + "minimum": 1, |
| 40 | + "propertyOrder": 2, |
| 41 | + }, |
| 42 | + "private_key": { |
| 43 | + "title": "private key", |
| 44 | + "type": "string", |
| 45 | + "minLength": 44, |
| 46 | + "maxLength": 44, |
| 47 | + "pattern": "^[^\\s]*$", |
| 48 | + "propertyOrder": 3, |
| 49 | + }, |
| 50 | + "peers": { |
| 51 | + "type": "array", |
| 52 | + "title": "Peers", |
| 53 | + "uniqueItems": True, |
| 54 | + "additionalItems": True, |
| 55 | + "propertyOrder": 11, |
| 56 | + "items": { |
| 57 | + "type": "object", |
| 58 | + "title": "Peer", |
| 59 | + "required": ["public_key", "allowed_ips"], |
| 60 | + "properties": { |
| 61 | + "public_key": { |
| 62 | + "title": "public key", |
| 63 | + "type": "string", |
| 64 | + "minLength": 44, |
| 65 | + "maxLength": 44, |
| 66 | + "pattern": "^[^\\s]*$", |
| 67 | + "propertyOrder": 1, |
| 68 | + }, |
| 69 | + "allowed_ips": { |
| 70 | + "title": "public key", |
| 71 | + "type": "string", |
| 72 | + "propertyOrder": 2, |
| 73 | + }, |
| 74 | + "endpoint": { |
| 75 | + "title": "public key", |
| 76 | + "type": "string", |
| 77 | + "propertyOrder": 3, |
| 78 | + }, |
| 79 | + "preshared_key": { |
| 80 | + "title": "pre-shared key", |
| 81 | + "type": "string", |
| 82 | + "minLength": 44, |
| 83 | + "maxLength": 44, |
| 84 | + "pattern": "^[^\\s]*$", |
| 85 | + "propertyOrder": 4, |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | + }, |
| 90 | + }, |
| 91 | + }, |
| 92 | + } |
| 93 | + }, |
| 94 | +} |
| 95 | + |
| 96 | +schema = deepcopy(base_wireguard_schema) |
| 97 | +schema['properties']['files'] = default_schema['properties']['files'] |
0 commit comments