[Fix] Support multiple wireguard tunnels on same device #657#666
Merged
Conversation
codesankalp
commented
Jun 24, 2022
Comment on lines
+34
to
+49
| def disallow_multiple_wireguard_tunneling(apps, schema_editor): | ||
| templates = get_wireguard_and_vxlan_wireguard_templates(apps).iterator() | ||
| for template in templates: | ||
| config = template.config | ||
| interfaces = config['interfaces'] | ||
| vpn_id = template.vpn.pk.hex | ||
| changed = False | ||
| for interface in interfaces: | ||
| if f'client_private_key_{vpn_id}' not in interface['private_key']: | ||
| continue | ||
| interface['private_key'] = '{{private_key}}' | ||
| changed = True | ||
| if not changed: | ||
| continue | ||
| template.config = config | ||
| template.save(update_fields=['config']) |
Member
Author
There was a problem hiding this comment.
I used this to unapply migration and thought it would be better to keep it here to revert the changes if anything goes wrong with the working of wireguard.
codesankalp
force-pushed
the
issues/657-multiple-wireguard-tunnels
branch
from
June 24, 2022 17:45
92bb836 to
3f52468
Compare
nemesifier
requested changes
Jun 24, 2022
| context_keys['server_ip_network'] | ||
| ] = f'{self.ip.ip_address}/{self.subnet.subnet.max_prefixlen}' | ||
| context[context_keys['vpn_subnet']] = str(self.subnet.subnet) | ||
| context[context_keys['private_key']] = '{{private_key}}' |
Member
There was a problem hiding this comment.
it's not super clear to me what is this used for?
Member
Author
There was a problem hiding this comment.
The length of private_key variable was longer than expected in validation when it was not defined, so I used this as boilerplate to pass a smaller length value which looks more like the previous one.
nemesifier
requested changes
Jun 24, 2022
codesankalp
force-pushed
the
issues/657-multiple-wireguard-tunnels
branch
from
June 24, 2022 19:45
b33e10f to
6f3bcce
Compare
nemesifier
approved these changes
Jun 24, 2022
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #657