Make ip for ip-check configurable
This commit is contained in:
parent
78625259c9
commit
9245b319d2
2 changed files with 9 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
events:
|
||||
cmd_address: "tcp://hugveycmd.local:5555"
|
||||
publish_address: "tcp://hugveycmd.local:5556"
|
||||
remote_ip: "192.168.1.1" # for stuf not on the Hugvey network, set it to eg. 8.8.8.8
|
||||
voice:
|
||||
input_rate: 44100
|
||||
target_rate: 16000
|
||||
|
|
|
@ -242,7 +242,7 @@ class VoiceServer(object):
|
|||
|
||||
|
||||
class CommandHandler(object):
|
||||
def __init__(self, hugvey_id, cmd_address, publish_address, file_address, play_audiodev = None, play_audiodriver=None):
|
||||
def __init__(self, hugvey_id, cmd_address, publish_address, file_address, play_audiodev = None, play_audiodriver=None, remote_ip='8.8.8.8'):
|
||||
self.eventQueue = []
|
||||
self.ctx = Context.instance()
|
||||
self.hugvey_id = hugvey_id
|
||||
|
@ -254,6 +254,7 @@ class CommandHandler(object):
|
|||
self.playingMsgId = None
|
||||
self.play_audiodev = play_audiodev
|
||||
self.play_audiodriver = play_audiodriver
|
||||
self.remote_ip = remote_ip
|
||||
# self.showMyself() # queue message for connection request
|
||||
|
||||
def handle(self, cmd):
|
||||
|
@ -387,11 +388,10 @@ class CommandHandler(object):
|
|||
'ip': self.getIp(),
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def getIp():
|
||||
def getIp(self):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
# TODO: make it a local ip, eg. 192.168.1.1
|
||||
s.connect(("192.168.1.1", 80))
|
||||
s.connect((self.remote_ip, 80))
|
||||
ip = s.getsockname()[0]
|
||||
s.close()
|
||||
return ip
|
||||
|
@ -480,6 +480,8 @@ class Hugvey(object):
|
|||
config=self.config
|
||||
)
|
||||
|
||||
remote_ip = self.config['events']['remote_ip'] if 'remote_ip' in self.config['events'] else '8.8.8.8'
|
||||
logger.debug("Using remote_ip for getIp: {}".format(remote_ip))
|
||||
self.cmd_server = CommandHandler(
|
||||
hugvey_id=self.id,
|
||||
cmd_address=self.config['events']['cmd_address'],
|
||||
|
@ -487,6 +489,7 @@ class Hugvey(object):
|
|||
file_address=self.config['voice']['file_address'],
|
||||
play_audiodev=self.voice_server.info['output']['device'],
|
||||
play_audiodriver=self.config['voice']['output_driver'] if 'output_driver' in self.config['voice'] else None,
|
||||
remote_ip=remote_ip,
|
||||
)
|
||||
|
||||
logger.info('start')
|
||||
|
|
Loading…
Reference in a new issue