-
Notifications
You must be signed in to change notification settings - Fork 22
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
Sourcery refactored master branch #31
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,7 @@ def get_platform(): | |
'darwin' : 'OS X', | ||
'win32' : 'Windows' | ||
} | ||
if sys.platform not in platforms: | ||
return sys.platform | ||
|
||
return platforms[sys.platform] | ||
return platforms.get(sys.platform, sys.platform) | ||
|
||
RIICONNECT24DNSSERVER_VERSION = "1.2" | ||
|
||
|
@@ -49,7 +46,7 @@ def get_ip(): | |
|
||
print("+===============================+") | ||
print("| RiiConnect24 DNS Server |") | ||
print("| Version " + RIICONNECT24DNSSERVER_VERSION + " |") | ||
print(f"| Version {RIICONNECT24DNSSERVER_VERSION} |") | ||
Comment on lines
-52
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
print("+===============================+\n") | ||
|
||
print("Hello! This server will allow you to connect to RiiConnect24 when your Internet Service Provider does not work with custom DNS.") | ||
|
@@ -132,24 +129,21 @@ def __init__(self, rdata_type, *args, rtype=None, rname=None, ttl=None, **kwargs | |
) | ||
|
||
def try_rr(self, q): | ||
if q.qtype == QTYPE.ANY or q.qtype == self._rtype: | ||
if q.qtype in [QTYPE.ANY, self._rtype]: | ||
Comment on lines
-135
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return self.as_rr(q.qname) | ||
|
||
def as_rr(self, alt_rname): | ||
return RR(rname=self._rname or alt_rname, rtype=self._rtype, **self.kwargs) | ||
|
||
def sensible_ttl(self): | ||
if self._rtype in (QTYPE.NS, QTYPE.SOA): | ||
return 60 * 60 * 24 | ||
else: | ||
return 300 | ||
return 60 * 60 * 24 if self._rtype in (QTYPE.NS, QTYPE.SOA) else 300 | ||
Comment on lines
-142
to
+139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
@property | ||
def is_soa(self): | ||
return self._rtype == QTYPE.SOA | ||
|
||
def __str__(self): | ||
return '{} {}'.format(QTYPE[self._rtype], self.kwargs) | ||
return f'{QTYPE[self._rtype]} {self.kwargs}' | ||
Comment on lines
-152
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
ZONES = {} | ||
|
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.
Function
get_platform
refactored with the following changes:reintroduce-else
)swap-if-else-branches
)assign-if-exp
)default-get
)