예제 #1
0
파일: server.py 프로젝트: iSasuke7/piccolo
    def get_external_ip(self, ip_getter: str) -> Iterator[Deferred]:
        print('Retrieving external IP from {!r} to generate server identifier.'.format(ip_getter))
        try:
            ip = yield self.getPage(ip_getter)
            ip = IPv4Address(ip.strip())
        except AddressValueError as e:
            print('External IP getter service returned invalid data.\n'
                  'Please check the "ip_getter" setting in your config.')
            return
        except Exception as e:
            print("Getting external IP failed:", e)
            return

        self.ip = ip
        self.identifier = make_server_identifier(ip, self.port)
        print('Server public ip address: {}:{}'.format(ip, self.port))
        print('Public aos identifier: {}'.format(self.identifier))
예제 #2
0
    async def get_external_ip(self, ip_getter: str) -> Iterator[Deferred]:
        log.info(
            'Retrieving external IP from {!r} to generate server identifier.'.format(ip_getter))
        try:
            async with aiohttp.ClientSession() as session:
                async with session.get(ip_getter) as response:
                    ip = await response.text()
                    ip = IPv4Address(ip.strip())
        except AddressValueError as e:
            log.warn('External IP getter service returned invalid data.\n'
                     'Please check the "ip_getter" setting in your config.')
            return
        except Exception as e:  # pylint: disable=broad-except
            log.warn("Getting external IP failed: {reason}", reason=e)
            return

        self.ip = ip
        self.identifier = make_server_identifier(ip, self.port)
        log.info('Server public ip address: {}:{}'.format(ip, self.port))
        log.info('Public aos identifier: {}'.format(self.identifier))
예제 #3
0
파일: run.py 프로젝트: Lwgano/pyspades
 def got_external_ip(self, ip):
     self.ip = ip
     self.identifier = make_server_identifier(ip, self.port)
     print 'Server identifier is %s' % self.identifier
예제 #4
0
파일: run.py 프로젝트: mrpizza123/pysnip
 def got_external_ip(self, ip):
     self.ip = ip
     self.identifier = make_server_identifier(ip, self.port)
     print 'Server identifier is %s' % self.identifier
예제 #5
0
파일: run.py 프로젝트: Lwgano/pyspades
 def datagramReceived(self, data, address):
     if self.pyspades_set is None or data != 'HI':
         return
     self.pyspades_set.add(make_server_identifier(address[0], address[1]))
예제 #6
0
 def datagramReceived(self, data, address):
     if self.pyspades_set is None or data != 'HI':
         return
     self.pyspades_set.add(make_server_identifier(address[0], address[1]))