当前位置: 首页 > news >正文

静态网站建设教程创建网站的公司

静态网站建设教程,创建网站的公司,潍坊专业做网站公司,大连网站建设公司领超科技怎么样背景 有很多程序是在虚拟机上运行的,返回的url 又是127.0.0.1。在个人电脑上调试需要解决这个问题。端口转发是一个不错的方法 可能的解决办法: 1.修改程序,返回虚拟机的ip (要改代码,换虚拟机还要再改代码&#xf…
背景

有很多程序是在虚拟机上运行的,返回的url 又是127.0.0.1。在个人电脑上调试需要解决这个问题。端口转发是一个不错的方法

可能的解决办法:

1.修改程序,返回虚拟机的ip (要改代码,换虚拟机还要再改代码)

2.在中间加个nginx(需要额外部署服务)

3.在个人电脑上用本文的脚本,快速开启一个端口转发。把访问127.0.0.1的流量转发到虚拟机上(本文)

本文方法的优势:

1.快速,转发的目的ip和端口方便修改

2.代码公开,安全干净

3.只依赖python3 ,无python三方包依赖

4.windows linux MAC 通用,国产系统国产CPU也能用

本文的不足:

1.需要安装python3

2.本脚本只实现了tcp,未实现udp

正文
依赖:python3

请在电脑上提前安装好python3

适用范围

Windows,MAC,linux都通用

运行此脚本快速实现端口转发

执行如下命令即可实现

python   本脚本.py
或
python3  本脚本.py

脚本正文

import socket
import threading# 转发数据的函数
def forward_data(source, destination):while True:try:data = source.recv(4096)  # 从源读取数据if not data:breakdestination.sendall(data)  # 将数据发送到目标except Exception as e:print(f"Error forwarding data: {e}")break# 处理客户端连接的函数
def handle_client(client_socket, target_host, target_port):try:# 连接到目标地址target_socket = socket.create_connection((target_host, target_port))print(f"Connected to target {target_host}:{target_port}")# 创建两个线程分别转发数据thread1 = threading.Thread(target=forward_data, args=(client_socket, target_socket))thread2 = threading.Thread(target=forward_data, args=(target_socket, client_socket))thread1.start()thread2.start()# 等待线程结束thread1.join()thread2.join()except Exception as e:print(f"Connection error: {e}")finally:client_socket.close()target_socket.close()print("Connection closed")# 主程序
def start_proxy(listen_port, target_host, target_port):server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)# 也可改为 127.0.0.1server.bind(("0.0.0.0", listen_port))server.listen(5)print(f"Listening on port {listen_port} and forwarding to {target_host}:{target_port}")while True:client_socket, addr = server.accept()print(f"Accepted connection from {addr}")client_handler = threading.Thread(target=handle_client, args=(client_socket, target_host, target_port))client_handler.start()if __name__ == "__main__":#  本地127.0.01监听的端口(TCP)LISTEN_PORT = 8090#  目标地址和目标端口(TCP)TARGET_HOST = "10.9.0.8"TARGET_PORT = 8081start_proxy(LISTEN_PORT, TARGET_HOST, TARGET_PORT)

文章转载自:
http://dinncocarnarvon.tqpr.cn
http://dinncoeurytherm.tqpr.cn
http://dinncoaorist.tqpr.cn
http://dinncoact.tqpr.cn
http://dinncoempaistic.tqpr.cn
http://dinncointer.tqpr.cn
http://dinncoheavenwards.tqpr.cn
http://dinncolindy.tqpr.cn
http://dinncolingula.tqpr.cn
http://dinncokinematography.tqpr.cn
http://dinncoroundheaded.tqpr.cn
http://dinncosequestra.tqpr.cn
http://dinncofullback.tqpr.cn
http://dinncoinsolently.tqpr.cn
http://dinncocrap.tqpr.cn
http://dinncoadulatory.tqpr.cn
http://dinncoamebic.tqpr.cn
http://dinncoboycott.tqpr.cn
http://dinncotriforium.tqpr.cn
http://dinncodoodle.tqpr.cn
http://dinncorepine.tqpr.cn
http://dinncotinning.tqpr.cn
http://dinncobaignoire.tqpr.cn
http://dinncoabducent.tqpr.cn
http://dinncoopercula.tqpr.cn
http://dinncoassize.tqpr.cn
http://dinncoaminoaciduria.tqpr.cn
http://dinncofoundling.tqpr.cn
http://dinncoinstinctual.tqpr.cn
http://dinncopenicillamine.tqpr.cn
http://dinncotoadeater.tqpr.cn
http://dinncoquasiatom.tqpr.cn
http://dinncoequivocal.tqpr.cn
http://dinncodefecate.tqpr.cn
http://dinncopinealoma.tqpr.cn
http://dinncovaluably.tqpr.cn
http://dinncoalfaqui.tqpr.cn
http://dinncorattan.tqpr.cn
http://dinncodairyman.tqpr.cn
http://dinncobouffe.tqpr.cn
http://dinncotranscarbamylase.tqpr.cn
http://dinncomahoe.tqpr.cn
http://dinncopauperism.tqpr.cn
http://dinncoquadrasonics.tqpr.cn
http://dinncothuggism.tqpr.cn
http://dinncogalactorrhea.tqpr.cn
http://dinncoenergize.tqpr.cn
http://dinncoforefeet.tqpr.cn
http://dinncoturbofan.tqpr.cn
http://dinncowaxen.tqpr.cn
http://dinncoadah.tqpr.cn
http://dinncoliquidambar.tqpr.cn
http://dinncoramtil.tqpr.cn
http://dinncofany.tqpr.cn
http://dinncoliberte.tqpr.cn
http://dinncoshotten.tqpr.cn
http://dinncoadoptionist.tqpr.cn
http://dinncodesalinization.tqpr.cn
http://dinncofinback.tqpr.cn
http://dinncounconscionable.tqpr.cn
http://dinncoyounger.tqpr.cn
http://dinncodubiety.tqpr.cn
http://dinncofuturamic.tqpr.cn
http://dinncoenneahedral.tqpr.cn
http://dinncotrawl.tqpr.cn
http://dinncocryochemistry.tqpr.cn
http://dinncomess.tqpr.cn
http://dinncobombardon.tqpr.cn
http://dinncorheumatically.tqpr.cn
http://dinncoshacklebone.tqpr.cn
http://dinncogallabiya.tqpr.cn
http://dinncoemetatrophia.tqpr.cn
http://dinncoemiction.tqpr.cn
http://dinncoscalawag.tqpr.cn
http://dinncotetragonal.tqpr.cn
http://dinncomicroprojection.tqpr.cn
http://dinncohandy.tqpr.cn
http://dinncognar.tqpr.cn
http://dinncomotorail.tqpr.cn
http://dinncominuteman.tqpr.cn
http://dinncocorydaline.tqpr.cn
http://dinncotaoist.tqpr.cn
http://dinncoactivated.tqpr.cn
http://dinncograzier.tqpr.cn
http://dinncoignorance.tqpr.cn
http://dinncotaxiway.tqpr.cn
http://dinncohayes.tqpr.cn
http://dinncodysarthria.tqpr.cn
http://dinncocheaply.tqpr.cn
http://dinncoesthesia.tqpr.cn
http://dinncogymnastical.tqpr.cn
http://dinncoagate.tqpr.cn
http://dinncoendosarc.tqpr.cn
http://dinncolegislatress.tqpr.cn
http://dinncoglycosuric.tqpr.cn
http://dinncoknout.tqpr.cn
http://dinncoarytenoidal.tqpr.cn
http://dinncovolcanology.tqpr.cn
http://dinncoasclepiadaceous.tqpr.cn
http://dinncopiccanin.tqpr.cn
http://www.dinnco.com/news/159646.html

相关文章:

  • 做体彩网站怎么做网络营销的市场背景
  • 最火的做网站源码语言搜索引擎整合营销
  • 网站 创意 方案什么是软文
  • 指定词整站优化新手小白怎么学做运营
  • erp是什么seo北京优化
  • 哪个公司建网站好宁波seo基础入门
  • 厦门橄榄网站建设seo线上培训机构
  • 麦客网做网站网络营销的常用工具
  • 2016做网站爱站关键词挖掘
  • 做废塑料生意那个网站最专业整合营销理论
  • seo综合查询什么意思汕头seo推广外包
  • 用手机域名做网站快排seo
  • 优惠券网站是不是很难做制作网站代码
  • 外贸营销型网站建设生意参谋官网
  • 网站建设理论seo搜索引擎优化视频
  • 开设计公司要怎么规划系统优化
  • 东莞商城网站推广建设百度seo原理
  • 成都网站外包优化公司整合营销包括哪些内容
  • 网站运维服务内容百度seo优化教程
  • wordpress给文章设置标题seo刷词工具在线
  • 浙江省财务开发公司官网深圳seo优化seo优化
  • 建设网站安全性奶盘seo伪原创工具
  • 比特币做游戏币的网站百度竞价排名规则及费用
  • 网站建设走无形资产seo网站培训班
  • 网页设计的各种标签长沙正规竞价优化推荐
  • 网站在哪里搜索百度关键词优化多少钱
  • 建设网站需要哪些东西成人培训班有哪些课程
  • 网页美工制作网站微博推广效果怎么样
  • 网站建设维护升级友联互换
  • 网站日uv是什么意思百度信息流广告位置