首页 > 解决方案 > 隐藏python服务器ip

问题描述

我想知道是否有任何方法可以隐藏 python 套接字服务器 ip(使用 tor 或代理)。

我知道您可以通过 tor 发出客户端请求,但我希望能够连接到服务器而不必知道他的真实 IP 地址(以 .onion 地址为例)

该代码将可访问,因此加密 ip 可能不是解决方案。

我现在的服务器代码:

import socket


s = socket.socket()
host = "192.168.1.1"
port = 9999
print(f"server will start on host:{host}")
s.bind((host, port))
print("Server is bond !")
s.listen(1)
client, address = s.accept()
print(address, "connected")

我的客户代码:

import socket


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

host = '192.168.1.18'#  ip address of the server (that I would like to hide)
port = 80

try:
    s.connect((host, port))
    print("connected !")
except:
    print("error !")

标签: pythonpython-3.xsockets

解决方案


推荐阅读