Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
domotikad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
domotika
domotikad
Commits
a720da39
Commit
a720da39
authored
Oct 14, 2016
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix DNS issues with CNAME resolution
parent
c11570b3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
12 deletions
+18
-12
domotika.py
domotika/domotika.py
+2
-2
nameserver.py
domotika/nameserver.py
+15
-9
domotikad
domotikad
+1
-1
No files found.
domotika/domotika.py
View file @
a720da39
...
...
@@ -120,6 +120,7 @@ class domotikaService(service.Service):
dmdb
.
initialize
(
self
.
config
)
def
isStarted
(
self
):
log
.
debug
(
"isStarted() called"
)
self
.
isConfigured
()
def
isConfigured
(
self
):
...
...
@@ -141,7 +142,6 @@ class domotikaService(service.Service):
self
.
thermoprgloop
=
txcron
.
ScheduledCall
(
self
.
thermoProgramLoop
)
self
.
thermoprgloop
.
start
(
CronSchedule
(
'00 * * * *'
))
self
.
actiontimer
.
start
(
int
(
self
.
config
.
get
(
"general"
,
"action_status_timer"
)))
self
.
timer
.
start
(
int
(
self
.
config
.
get
(
"ikapserver"
,
"timeupdates"
)))
if
self
.
config
.
get
(
"general"
,
"timeserver"
)
.
lower
()
in
[
'yes'
,
'y'
,
'1'
,
'true'
,
'on'
]:
...
...
@@ -155,7 +155,6 @@ class domotikaService(service.Service):
flags
=
task
.
LoopingCall
(
self
.
cleanFlags
)
flags
.
start
(
1
)
self
.
startUPNPService
()
self
.
startAsteriskServices
()
self
.
initializeCrontab
()
...
...
@@ -168,6 +167,7 @@ class domotikaService(service.Service):
self
.
startVLC
()
self
.
startOpenWeatherMap
()
self
.
initialized
=
True
log
.
debug
(
"isConfigured() called"
)
def
startOpenWeatherMap
(
self
):
weather
.
OWMWeather
(
self
.
config
.
get
(
"geo"
,
"latitude"
),
...
...
domotika/nameserver.py
View file @
a720da39
...
...
@@ -35,13 +35,15 @@ TO = '127.0.0.1'
TTL
=
60
class
DNSServerFactory
(
server
.
DNSServerFactory
):
def
gotResolverResponse
(
self
,
(
ans
,
auth
,
add
),
protocol
,
message
,
address
):
def
gotResolverResponse
(
self
,
records
,
protocol
,
message
,
address
):
ans
,
auth
,
add
=
records
ans2
=
[]
qname
=
message
.
queries
[
0
]
.
name
.
name
if
self
.
dmhost
in
qname
:
for
answer
in
ans
:
if
answer
.
type
!=
dns
.
A
:
continue
if
not
answer
.
name
.
name
.
endswith
(
self
.
dmhost
):
if
(
answer
.
type
!=
dns
.
A
and
answer
.
type
!=
dns
.
CNAME
)
or
not
answer
.
name
.
name
.
endswith
(
self
.
dmhost
):
if
answer
.
type
!=
dns
.
CNAME
and
answer
.
type
!=
dns
.
A
:
ans2
.
append
(
answer
)
continue
to
=
self
.
dmip
...
...
@@ -53,14 +55,18 @@ class DNSServerFactory(server.DNSServerFactory):
to
=
netifaces
.
ifaddresses
(
self
.
dmiface
+
':0'
)[
2
][
0
][
'addr'
]
except
:
to
=
'10.224.207.1'
answer
.
payload
.
address
=
socket
.
inet_aton
(
to
)
answer
.
payload
.
ttl
=
TTL
answer
.
type
=
dns
.
A
answer
.
payload
=
dns
.
Record_A
(
to
,
TTL
)
#answer.payload.address = socket.inet_aton(to)
#answer.payload.ttl = TTL
ans2
.
append
(
answer
)
if
len
(
ans2
)
>
0
:
ans
=
ans2
args
=
(
self
,
(
ans
,
auth
,
add
),
protocol
,
message
,
address
)
return
server
.
DNSServerFactory
.
gotResolverResponse
(
*
args
)
def
startDNS
(
host
=
"q.
unixmedia
.net"
,
ip
=
"auto"
,
iface
=
"eth0"
,
servers
=
[(
'8.8.8.8'
,
53
)]):
def
startDNS
(
host
=
"q.
nexlab
.net"
,
ip
=
"auto"
,
iface
=
"eth0"
,
servers
=
[(
'8.8.8.8'
,
53
)]):
verbosity
=
0
resolver
=
client
.
Resolver
(
servers
=
servers
)
factory
=
DNSServerFactory
(
clients
=
[
resolver
],
verbose
=
verbosity
)
...
...
@@ -75,5 +81,5 @@ def startDNS(host="q.unixmedia.net", ip="auto", iface="eth0", servers=[('8.8.8.8
if
__name__
==
'__main__'
:
startDNS
(
'q.
unixmedia
.net'
,
'auto'
)
startDNS
(
'q.
nexlab
.net'
,
'auto'
)
reactor
.
run
()
domotikad
View file @
a720da39
...
...
@@ -26,7 +26,7 @@ from twisted.internet import epollreactor
epollreactor
.
install
()
from
twisted.internet
import
reactor
,
ssl
,
protocol
from
twisted.internet
import
reactor
,
ssl
,
protocol
,
endpoints
from
twisted.application
import
service
,
internet
,
app
,
reactors
from
twisted.web
import
server
#, soap
import
logging
,
time
,
sys
,
os
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment