-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to add DNS resolvers to a site #104
Open
0ff
wants to merge
3
commits into
DefinedNet:main
Choose a base branch
from
0ff:feature/dns-resolvers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; | ||
import 'package:mobile_nebula/components/FormPage.dart'; | ||
import 'package:mobile_nebula/components/IPFormField.dart'; | ||
import 'package:mobile_nebula/components/config/ConfigItem.dart'; | ||
import 'package:mobile_nebula/components/config/ConfigSection.dart'; | ||
import 'package:mobile_nebula/services/utils.dart'; | ||
|
||
class DNSResolverScreen extends StatefulWidget { | ||
const DNSResolverScreen({Key? key, required this.dnsResolver, required this.onDelete, required this.onSave}) : super(key: key); | ||
|
||
final String dnsResolver; | ||
final ValueChanged<String> onSave; | ||
final Function onDelete; | ||
|
||
@override | ||
_DNSResolverScreenState createState() => _DNSResolverScreenState(); | ||
} | ||
|
||
class _DNSResolverScreenState extends State<DNSResolverScreen> { | ||
late String dnsResolver; | ||
bool changed = false; | ||
|
||
FocusNode dnsResolverFocus = FocusNode(); | ||
|
||
@override | ||
void initState() { | ||
dnsResolver = widget.dnsResolver; | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FormPage( | ||
title: widget.onDelete == null ? 'New DNS Resolver' : 'Edit DNS Resolver', | ||
changed: changed, | ||
onSave: _onSave, | ||
child: Column(children: [ | ||
ConfigSection(children: <Widget>[ | ||
ConfigItem( | ||
label: Text('Address'), | ||
content: IPFormField( | ||
initialValue: dnsResolver, | ||
ipOnly: true, | ||
textInputAction: TextInputAction.next, | ||
focusNode: dnsResolverFocus, | ||
onSaved: (v) { | ||
dnsResolver = v.toString(); | ||
})), | ||
]), | ||
widget.onDelete != null | ||
? Padding( | ||
padding: EdgeInsets.only(top: 50, bottom: 10, left: 10, right: 10), | ||
child: SizedBox( | ||
width: double.infinity, | ||
child: PlatformElevatedButton( | ||
child: Text('Delete'), | ||
color: CupertinoColors.systemRed.resolveFrom(context), | ||
onPressed: () => Utils.confirmDelete(context, 'Delete DNS Resolver?', () { | ||
Navigator.of(context).pop(); | ||
widget.onDelete(); | ||
}), | ||
))) | ||
: Container() | ||
])); | ||
} | ||
|
||
_onSave() { | ||
Navigator.pop(context); | ||
if (widget.onSave != null) { | ||
widget.onSave(dnsResolver); | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cm.getLinkProperties(network)?.dnsServers?.forEach { builder.addDnsServer(it) }
Would not compile otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, lines 129 to 132 should be removed entirely, as they cause a DNS leak on Android when tested with https://mullvad.net/ (but no others, interestingly). Removing these lines fixes the DNS leak. They are also based on a false assumption that the device will not roam between networks.