示例#1
0
    def location(self):
        """ Determines the location of the client accounting for typical proxy settings.
            In the event the request is coming from the same machine / loop back ip
            we'll attempt to resolve the actual IP address for the machine """

        if 'X-Real-IP' in request.headers:
            remote_addr = request.headers.get('X-Real-IP')
        elif 'X-Forwarded-For' in request.headers:
            remote_addr = request.headers.getlist(
                "X-Forwarded-For")[0].rpartition(' ')[-1]
        else:
            remote_addr = getattr(request, "remote_addr", "untrackable")

        if remote_addr == "127.0.0.1" or remote_addr.startswith("192.168."):
            try:
                remote_addr = get_ip(GoogleDnsProvider)
            except Exception as e:
                print(str(e))
                remote_addr = "untrackable"

        details = None
        if remote_addr != "untrackable":
            details = ipinfo.getHandler(self.token).getDetails(remote_addr).all
        return details
示例#2
0
                           cwd=self.repo_path)
        except subprocess.CalledProcessError as e:
            logger.warning("Error while uploading model:", e.output)


if __name__ == '__main__':
    parser = HfArgumentParser(
        (CoordinatorArguments, CollaborativeOptimizerArguments,
         AveragerArguments))
    coordinator_args, collab_optimizer_args, averager_args = parser.parse_args_into_dataclasses(
    )

    if coordinator_args.address is None:
        logger.warning(
            "No address specified. Attempting to infer address from DNS.")
        coordinator_args.address = get_ip(GoogleDnsProvider)

    experiment_prefix = coordinator_args.experiment_prefix
    validators, local_public_key = metrics_utils.make_validators(
        experiment_prefix)
    dht = hivemind.DHT(start=True,
                       listen_on=coordinator_args.dht_listen_on,
                       endpoint=f"{coordinator_args.address}:*",
                       initial_peers=coordinator_args.initial_peers,
                       record_validators=validators)

    logger.info(f"Running DHT root at {coordinator_args.address}:{dht.port}")

    if coordinator_args.wandb_project is not None:
        wandb.init(project=coordinator_args.wandb_project)
示例#3
0
def register_user():
    ip = get_ip(GoogleDnsProvider)
    body = {"ip": ip, "apiversion": apiversion}
    response = requests.post(urls.user, json=body)
    result = response.json()
    return result["uid"]
示例#4
0
def handler(event, context):
    ipaddr = get_ip(GoogleDnsProvider)
    return {'statusCode': 200, 'body': json.dumps(ipaddr)}
def get_public_ip():
    from whatsmyip.ip import get_ip
    from whatsmyip.providers import GoogleDnsProvider
    return get_ip(GoogleDnsProvider)
示例#6
0
文件: main.py 项目: Ecno92/myip
def main(provider: str) -> None:
    provider_cls = ip_providers[provider]
    ip = get_ip(provider_cls)
    click.echo(ip)
示例#7
0
def register_user(uid):
    ip = get_ip(GoogleDnsProvider)
    body = {"uid": uid, "ip": ip}
    response = requests.post(urls.user, json=body)
    return response.ok and response.json()["success"]
示例#8
0
文件: test_ip.py 项目: Ecno92/myip
def test_get_ip(mocked_fetch):
    provider = IpProvider
    get_ip(provider)
    assert provider.fetch.called is True
示例#9
0
def whats_my_ip():
    host = '8.8.8.8'
    port = 53
    try:
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))

    except socket.error:
        print(
            'MikkOS cannot establish an internet connection using this device. Please make sure your '
            'device is connected to the internet, and if the error persists please contact the '
            'MikkOS support team.')

    else:
        print("[1] - What's My IP;" "\n[2] - Exit;")
        tool = int(input('> Option: '))

        if tool == 1:
            date = datetime.now()
            sys_date = str(date.strftime("%d-%m-%Y %H:%M:%S"))
            sys_log = open("logs.txt", "a")
            sys_log.write(f"[{sys_date}] - What's My IP tool selected.\n")
            sys_log.close()

            user_ip = get_ip(GoogleDnsProvider)
            print(f"Your IP is: {user_ip}")

            date = datetime.now()
            sys_date = str(date.strftime("%d-%m-%Y %H:%M:%S"))
            sys_log = open("logs.txt", "a")
            sys_log.write(
                f"[{sys_date}] - User checked his IP. User IP: {user_ip}\n")
            sys_log.close()

        if tool == 2:
            print("Quitting What's My IP tool...")
            sleep(1)
            print("What's My IP tool Quitted. ")

            date = datetime.now()
            sys_date = str(date.strftime("%d-%m-%Y %H:%M:%S"))
            sys_log = open("logs.txt", "a")
            sys_log.write(f"[{sys_date}] - What's My IP tool Quitted.\n")
            sys_log.close()

        while tool != 2:
            print("[1] - What's My IP;" "\n[2] - Exit;")
            tool = int(input('> Option: '))

            if tool == 1:
                date = datetime.now()
                sys_date = str(date.strftime("%d-%m-%Y %H:%M:%S"))
                sys_log = open("logs.txt", "a")
                sys_log.write(f"[{sys_date}] What's My IP tool selected.\n")
                sys_log.close()

                user_ip = get_ip(GoogleDnsProvider)
                print(f"Your IP is: {user_ip}")

                date = datetime.now()
                sys_date = str(date.strftime("%d-%m-%Y %H:%M:%S"))
                sys_log = open("logs.txt", "a")
                sys_log.write(
                    f"[{sys_date}] - User checked his IP. User IP: {user_ip}\n"
                )
                sys_log.close()

            if tool == 2:
                print("Quitting What's My IP tool...")
                sleep(1)
                print("What's My IP tool Quitted. ")

                date = datetime.now()
                sys_date = str(date.strftime("%d-%m-%Y %H:%M:%S"))
                sys_log = open("logs.txt", "a")
                sys_log.write(f"[{sys_date}] - What's My IP tool Quitted.\n")
                sys_log.close()