Skip to content
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

Added py3dns recipe #728

Merged
merged 5 commits into from Jul 10, 2022
Merged

Added py3dns recipe #728

merged 5 commits into from Jul 10, 2022

Conversation

Neizvestnyj
Copy link
Contributor

Same as in the android, but I change localhost to 8.8.8.8

from kivy.app import App
from kivy.uix.button import Button

import DNS
import smtplib


class TestApp(App):
    def build(self):
        return Button(text='Get DNS',
                      on_release=lambda *args: print(self.get_dns_host('gmail.com')),
                      )

    @staticmethod
    def get_dns_host(hostname: str, timeout=5):
        valid_host = None
        try:
            DNS.DiscoverNameServers()
            mx_hosts = DNS.mxlookup(hostname, timeout)
            for mx in mx_hosts:
                smtp = smtplib.SMTP()
                try:
                    smtp.connect(mx[1])
                except smtplib.SMTPConnectError:
                    continue  # try the next MX server in list
                else:
                    valid_host = mx[1]
        except Exception as err:
            print(err)

        return valid_host


TestApp().run()

Screenshot 2022-07-09 at 00 07 33

Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait for the CI to do its jobs, but overall looks good.
I'm only worried about forcing users to use 8.8.8.8 without warning them.

Did you checked for alternate solutions? (E.g. Like exposing an API via the ios module?)

If we decide that using the Google DNS is the only feasible and easy way to do it, how about including ´8.8.4.4´ as a fallback?

@Neizvestnyj
Copy link
Contributor Author

Let's wait for the CI to do its jobs, but overall looks good. I'm only worried about forcing users to use 8.8.8.8 without warning them.

Did you checked for alternate solutions? (E.g. Like exposing an API via the ios module?)

If we decide that using the Google DNS is the only feasible and easy way to do it, how about including ´8.8.4.4´ as a fallback?

I dont now how to use ios module for that, but using 8.8.4.4 is a good solution (and easy). For exmaple we try to check 8.8.8.8 using socket, if it does not be used, we switch to 8.8.4.4

Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI noticed an issue on PEP8 checks, can you take care of it?

@Neizvestnyj
Copy link
Contributor Author

The CI noticed an issue on PEP8 checks, can you take care of it?

yes, I make new commit with some patch fixes

@Neizvestnyj
Copy link
Contributor Author

Neizvestnyj commented Jul 9, 2022

@misl6 How about this check script?

import socket

def check_host(host="8.8.8.8", port=53, timeout=3):
    """
    Host: 8.8.8.8 (google-public-dns-a.google.com)
    OpenPort: 53/tcp
    Service: domain (DNS/TCP)
    """
    try:
        socket.setdefaulttimeout(timeout)
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
        return True
    except socket.error as ex:
        return False

host = "8.8.8.8"
if not check_host(host):
	host = "8.8.4.4"

@misl6
Copy link
Member

misl6 commented Jul 9, 2022

@misl6 How about this check script?

import socket

def check_host(host="8.8.8.8", port=53, timeout=3):
    """
    Host: 8.8.8.8 (google-public-dns-a.google.com)
    OpenPort: 53/tcp
    Service: domain (DNS/TCP)
    """
    try:
        socket.setdefaulttimeout(timeout)
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
        return True
    except socket.error as ex:
        return False

host = "8.8.8.8"
if not check_host(host):
	host = "8.8.4.4"

Isn't defaults['server'] = ['8.8.8.8', '8.8.4.4'] instead of defaults['server'].append('8.8.8.8') enough?

@Neizvestnyj
Copy link
Contributor Author

['8.8.8.8', '8.8.4.4']

Of course, I dont think about it :)

@Neizvestnyj
Copy link
Contributor Author

@misl6 Done

@Neizvestnyj Neizvestnyj requested a review from misl6 July 9, 2022 16:58
Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. Looks like the patch contains some extra un-needed lines.
Can you take care of it?

kivy_ios/recipes/py3dns/ios.patch Outdated Show resolved Hide resolved
kivy_ios/recipes/py3dns/ios.patch Outdated Show resolved Hide resolved
kivy_ios/recipes/py3dns/ios.patch Outdated Show resolved Hide resolved
@Neizvestnyj Neizvestnyj requested a review from misl6 July 10, 2022 08:32
kivy_ios/recipes/py3dns/ios.patch Outdated Show resolved Hide resolved
@Neizvestnyj Neizvestnyj requested a review from misl6 July 10, 2022 09:12
Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The automated tests on changed recipes are now failing due to a malformed patch.

2022-07-10T08:59:48.6004950Z   STDERR:
2022-07-10T08:59:48.6005440Z /usr/bin/patch: **** malformed patch at line 13: @@ -50,8 +51,12 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY,

Can you test it locally and check the patch?

@Neizvestnyj Neizvestnyj requested a review from misl6 July 10, 2022 11:23
@Neizvestnyj
Copy link
Contributor Author

Neizvestnyj commented Jul 10, 2022

The automated tests on changed recipes are now failing due to a malformed patch.

2022-07-10T08:59:48.6004950Z   STDERR:
2022-07-10T08:59:48.6005440Z /usr/bin/patch: **** malformed patch at line 13: @@ -50,8 +51,12 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY,

Can you test it locally and check the patch?

I update patch file.
I download this and unpack https://launchpad.net/py3dns/trunk/3.2.1/+download/py3dns-3.2.1.tar.gz

cd py3dns-3.2.1
git init
git add .
git commit -m "test"
# make changes in file
git diff > ios.patch

Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@misl6 misl6 merged commit 6446352 into kivy:master Jul 10, 2022
@Neizvestnyj Neizvestnyj deleted the py3dns branch July 14, 2022 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants