Пример #1
0
    def start(self, loop):
        from calibre.utils.mdns import publish, unpublish, get_external_ip, verify_ipV4_address
        ip_address, port = loop.bound_address[:2]
        self.zeroconf_ip_address = zipa = verify_ipV4_address(
            ip_address) or get_external_ip()
        prefix = loop.opts.url_prefix or ''
        mdns_services = ((self.service_name, self.service_type, port, {
            'path': prefix + self.path
        }), )
        if self.shutdown.is_set():
            return
        self.services = []

        for s in mdns_services:
            self.services.append(
                publish(*s,
                        use_ip_address=zipa,
                        add_hostname=self.add_hostname))
        loop.log('OPDS feeds advertised via BonJour at: %s port: %s' %
                 (zipa, port))
        self.advertised_port = port
        self.started.set()

        self.shutdown.wait()
        for s in mdns_services:
            unpublish(*s,
                      add_hostname=self.add_hostname,
                      wait_for_stop=self.wait_for_stop)
        self.stopped.set()
Пример #2
0
    def start(self, loop):
        from calibre.utils.mdns import publish, unpublish, get_external_ip, verify_ipV4_address
        ip_address, port = loop.bound_address[:2]
        self.zeroconf_ip_address = zipa = verify_ipV4_address(ip_address) or get_external_ip()
        prefix = loop.opts.url_prefix or ''
        # The Zeroconf module requires everything to be bytestrings

        def enc(x):
            if not isinstance(x, bytes):
                x = x.encode('ascii')
            return x
        mdns_services = (
            (enc(self.service_name), enc(self.service_type), port, {b'path':enc(prefix + self.path)}),
        )
        if self.shutdown.is_set():
            return
        self.services = []

        for s in mdns_services:
            self.services.append(publish(*s, use_ip_address=zipa, add_hostname=self.add_hostname))
        loop.log('OPDS feeds advertised via BonJour at: %s port: %s' % (zipa, port))
        self.advertised_port = port
        self.started.set()

        self.shutdown.wait()
        for s in mdns_services:
            unpublish(*s, add_hostname=self.add_hostname)
        self.stopped.set()
Пример #3
0
 def start(self):
     zeroconf_ip_address = verify_ipV4_address(self.ip_address)
     try:
         for s in self.mdns_services:
             publish_zeroconf(*s, use_ip_address=zeroconf_ip_address)
     except:
         import traceback
         cherrypy.log.error('Failed to start BonJour:')
         cherrypy.log.error(traceback.format_exc())
Пример #4
0
 def start(self):
     zeroconf_ip_address = verify_ipV4_address(self.ip_address)
     try:
         for s in self.mdns_services:
             publish_zeroconf(*s, use_ip_address=zeroconf_ip_address)
     except:
         import traceback
         cherrypy.log.error('Failed to start BonJour:')
         cherrypy.log.error(traceback.format_exc())
Пример #5
0
    def server_state_changed(self, running):
        from calibre.utils.mdns import get_external_ip, verify_ipV4_address

        text = _("Start Content Server")
        if running:
            listen_on = verify_ipV4_address(tweaks["server_listen_on"]) or get_external_ip()
            try:
                cs_port = content_server_config().parse().port
                ip_text = _(" [%(ip)s, port %(port)d]") % dict(ip=listen_on, port=cs_port)
            except:
                ip_text = " [%s]" % listen_on
            text = _("Stop Content Server") + ip_text
        self.toggle_server_action.setText(text)
Пример #6
0
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content Server')
     if running:
         listen_on = (verify_ipV4_address(tweaks['server_listen_on']) or
                 get_external_ip())
         try :
             cs_port = content_server_config().parse().port
             ip_text = _(' [%s, port %d]')%(listen_on, cs_port)
         except:
             ip_text = ' [%s]'%listen_on
         text = _('Stop Content Server') + ip_text
     self.toggle_server_action.setText(text)
Пример #7
0
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content Server')
     if running:
         listen_on = (verify_ipV4_address(tweaks['server_listen_on'])
                      or get_external_ip())
         try:
             cs_port = content_server_config().parse().port
             ip_text = _(' [%(ip)s, port %(port)d]') % dict(ip=listen_on,
                                                            port=cs_port)
         except:
             ip_text = ' [%s]' % listen_on
         text = _('Stop Content Server') + ip_text
     self.toggle_server_action.setText(text)
Пример #8
0
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content server')
     if running:
         from calibre.srv.opts import server_config
         opts = server_config()
         listen_on = verify_ipV4_address(opts.listen_on) or get_external_ip()
         try:
             ip_text = _(' [%(ip)s, port %(port)d]')%dict(
                 ip=listen_on, port=opts.port)
         except Exception:
             ip_text = ' [%s]'%listen_on
         text = _('Stop Content server') + ip_text
     self.toggle_server_action.setText(text)
Пример #9
0
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content server')
     if running:
         from calibre.srv.opts import server_config
         opts = server_config()
         listen_on = verify_ipV4_address(opts.listen_on) or get_external_ip()
         protocol = 'HTTPS' if opts.ssl_certfile and opts.ssl_keyfile else 'HTTP'
         try:
             ip_text = ' ' + _('[{ip}, port {port}, {protocol}]').format(
                     ip=listen_on, port=opts.port, protocol=protocol)
         except Exception:
             ip_text = ' [{} {}]'.format(listen_on, protocol)
         self.ip_text = ip_text
         self.server_state_changed_signal.emit(running, ip_text)
         text = _('Stop Content server') + ip_text
     else:
         self.ip_text = ''
     self.toggle_server_action.setText(text)
Пример #10
0
    def start(self, loop):
        from calibre.utils.mdns import publish, unpublish, get_external_ip, verify_ipV4_address
        ip_address, port = loop.bound_address[:2]
        self.zeroconf_ip_address = zipa = verify_ipV4_address(ip_address) or get_external_ip()
        prefix = loop.opts.url_prefix or ''
        mdns_services = (
            (self.service_name, self.service_type, port, {'path':prefix + self.path}),
        )
        if self.shutdown.is_set():
            return
        self.services = []

        for s in mdns_services:
            self.services.append(publish(*s, use_ip_address=zipa, add_hostname=self.add_hostname))
        loop.log('OPDS feeds advertised via BonJour at: %s port: %s' % (zipa, port))
        self.advertised_port = port
        self.started.set()

        self.shutdown.wait()
        for s in mdns_services:
            unpublish(*s, add_hostname=self.add_hostname, wait_for_stop=self.wait_for_stop)
        self.stopped.set()