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

十大接单网站网站推广优化的公司

十大接单网站,网站推广优化的公司,做的网站如何全屏,网站海外推广平台wmproxy wmproxy是由Rust编写,已实现http/https代理,socks5代理, 反向代理,静态文件服务器,内网穿透,配置热更新等, 后续将实现websocket代理等,同时会将实现过程分享出来&#xff…

wmproxy

wmproxy是由Rust编写,已实现http/https代理,socks5代理, 反向代理,静态文件服务器,内网穿透,配置热更新等, 后续将实现websocket代理等,同时会将实现过程分享出来, 感兴趣的可以一起造个轮子法

项目 ++wmproxy++

gite: https://gitee.com/tickbh/wmproxy

github: https://github.com/tickbh/wmproxy

内网、公网

内网:也叫做局域网,通常指单一的网络环境。例如你家里的路由器网络、网吧、公司网络、学校网络。网络大小不定,内网中的主机可以互联互通,但是越出这个局域网访问,就无法访问该网络中的主机。

公网:就是互联网,其实也可以看做一个扩大版的内网,比如叫城际网,省域网,国网。有单独的公网IP,任何其它地址可以访问网络的可以直接访问该IP,从而实现服务。

为什么要内网穿透

内网限制

  1. IP不固定,通过家庭网,手机4G/5G访问的出口地址都是动态的,每次连接都会变化
  2. 运营商通常会做NAT转化,从而实际上你访问的出口地址其实也是一个内网地址,如通常https://www.baidu.com/s?wd=ip查询地址
  3. 常用端口无法使用,如80/443这类标准端口被直接限制不能使用。

公网优缺点

  1. 服务器贵,带宽贵
  2. IP固定,所有端口均可开放
  3. 带宽稳定,基本上所有高防机房或者云厂商都能提供稳定的带宽

内网穿透的场景

场景1:开发人员本地调试接口

描述:线上项目有问题或者有某些新功能,必须进行Debug进行调试和测试。
特点:本地调试、网速要求低、需要HTTP或者HTTPS协议。
需求:必须本地,必须HTTP[S]网址。

场景2:公司或者家里的本地存储或者公司内部系统

描述:如外出进行工作,或者本地有大量的私有数据(敏感不适合上云),但是自己必须得进行访问,如git服务或者照片服务等
特点:需要远程能随时随地的访问,访问内容不确定,但是需要能提供
需求:要相对比较稳定的线路,但是带宽相对要求较低

场景3:私有服务器和小伙伴开黑

描述:把自己的电脑做服务器,有时候云上的主机配置相对较高点的一个月费用极高,所以需要本地做私有服务器,或者把自己当做一台训练机
特点:对稳定性要求不用太高的,可以提供相应的服务

TCP内网穿透的原理

内网IP无法直接被访问,所以此时需求

  1. 内网服务器
  2. 公网服务器,有公网IP

此时网络如下,如此外部用户就能访问到内网服务器的数据,此时内网穿透客户端及服务端是保持长连接以方便进行推送,本质上是长链接在转发数据而实现穿透功能

由穿透客户端连接到内网服务器
建立连接/保持连接
访问建立连接
内网服务器
内网穿透客户端wmproxy
内网穿透服务端wmproxy
外网用户

Rust实现内网穿透

wmproxy一款简单易用的内网穿透工具,简单示例如下:

客户端相关

客户端配置client.yaml

# 连接服务端地址
server: 127.0.0.1:8091
# 连接服务端是否加密
ts: true# 内网映射配置的数组
mappings:#将localhost的域名转发到本地的127.0.0.1:8080- name: webmode: httplocal_addr: 127.0.0.1:8080domain: localhost#将tcp的流量无条件转到127.0.0.1:8080- name: tcpmode: tcplocal_addr: 127.0.0.1:8080domain: 

启动客户端

wmproxy -c config/client.yaml

服务端相关

服务端配置server.yaml

#绑定的ip地址
bind_addr: 127.0.0.1:8091
#代理支持的功能,1为http,2为https,4为socks5
flag: 7
#内网映射http绑定地址
map_http_bind: 127.0.0.1:8001
#内网映射tcp绑定地址
map_tcp_bind: 127.0.0.1:8002
#内网映射https绑定地址
map_https_bind: 127.0.0.1:8003
#内网映射的公钥证书,为空则是默认证书
map_cert: 
#内网映射的私钥证书,为空则是默认证书
map_key:
#接收客户端是为是加密客户端
tc: true
#当前服务模式,server为服务端,client为客户端
mode: server

启动服务端

wmproxy -c config/server.yaml

测试实现

在本地的8080端口上启动了一个简单的http文件服务器

http-server .
http测试

此时,8001的端口是http内网穿透通过服务端映射到客户端,并指向到8080端口,此时若访问http://127.0.0.1:8001则会显示在这里插入图片描述

http映射是根据域名做映射此时我们的域名是127.0.0.1,所以直接返回404无法访问
此时若访问http://localhost:8001,结果如下
在这里插入图片描述

我们就可以判定我们的内网转发成功了。

tcp测试

tcp就是在该端口上的流量无条件转发到另一个端口上,此时我们可以预测tcp映射与域名无关,我们在8002上转发到了8080上,此时我们访问http://127.0.0.1:8002http://localhost:8002都可以得到一样的结果
在这里插入图片描述

此时tcp转发成功

源码实现

因为TLS连接与协议无关,只要把普通的TCP转成TLS,剩下的均和普通连接一样处理即可,那么,此时我们只需要处理TCP和HTTP的请求转发即可。

监听

在程序启动的时候看我们是否配置了相应的http/https/tcp的内网穿透转发,如果有我们对相应的端口做监听,此时如果我们是https转发,要配置相应的证书,将会对TcpStream升级为TlsStream<TcpStream>

let http_listener = if let Some(ls) = &self.option.map_http_bind {Some(TcpListener::bind(ls).await?)
} else {None
};
let mut https_listener = if let Some(ls) = &self.option.map_https_bind {Some(TcpListener::bind(ls).await?)
} else {None
};let map_accept = if https_listener.is_some() {let map_accept = self.option.get_map_tls_accept().await.ok();if map_accept.is_none() {let _ = https_listener.take();}map_accept
} else {None
};
let tcp_listener = if let Some(ls) = &self.option.map_tcp_bind {Some(TcpListener::bind(ls).await?)
} else {None
};

转发相关代码,主要在两个类里,分别为trans/http.rstrans/tcp.rs

http里面需要预处理相关的头文件消息,

  • X-Forwarded-For添加IP信息,从而使内网可以知道访问的IP来源
  • Host,重写Host信息,让内网端如果配置负载均衡可以正确的定位到位置
  • Server,重写Server信息,让内网可以明确知道这个服务端的类型
http转发源码

以下为部分代码,后续将进行比较正规的HTTP服务,以适应HTTP2

pub async fn process<T>(self, mut inbound: T) -> Result<(), ProxyError<T>>
whereT: AsyncRead + AsyncWrite + Unpin,
{let mut request;let host_name;let mut buffer = BinaryMut::new();loop {// 省略读信息request = webparse::Request::new();// 通过该方法解析标头是否合法, 若是partial(部分)则继续读数据// 若解析失败, 则表示非http协议能处理, 则抛出错误// 此处clone为浅拷贝,不确定是否一定能解析成功,不能影响偏移match request.parse_buffer(&mut buffer.clone()) {Ok(_) => match request.get_host() {Some(host) => {host_name = host;break;}None => {if !request.is_partial() {Self::err_server_status(inbound, 503).await?;return Err(ProxyError::UnknownHost);}}},// 数据不完整,还未解析完,等待传输Err(WebError::Http(HttpError::Partial)) => {continue;}Err(e) => {Self::err_server_status(inbound, 503).await?;return Err(ProxyError::from(e));}}}// 取得相关的host数据,对内网的映射端做匹配,如果未匹配到返回错误,表示不支持{let mut is_find = false;let read = self.mappings.read().await;for v in &*read {if v.domain == host_name {is_find = true;}}if !is_find {Self::not_match_err_status(inbound, "no found".to_string()).await?;return Ok(());}}// 有新的内网映射消息到达,通知客户端建立对内网指向的连接进行双向绑定,后续做正规的http服务以支持拓展let create = ProtCreate::new(self.sock_map, Some(host_name));let (stream_sender, stream_receiver) = channel::<ProtFrame>(10);let _ = self.sender_work.send((create, stream_sender)).await;// 创建传输端进行绑定let mut trans = TransStream::new(inbound, self.sock_map, self.sender, stream_receiver);trans.reader_mut().put_slice(buffer.chunk());trans.copy_wait().await?;// let _ = copy_bidirectional(&mut inbound, &mut outbound).await?;Ok(())
}
tcp转发源码

tcp处理相对比较简单,因为我们无法确定协议里是哪个类型的源码,所以对我们来说,就是单纯的把接收的数据完全转发到新的端口里。以下是部分源码

pub async fn process<T>(self, inbound: T) -> Result<(), ProxyError<T>>
whereT: AsyncRead + AsyncWrite + Unpin,
{// 寻找是否有匹配的tcp转发协议,如果有,则进行转发,如果没有则丢弃数据{let mut is_find = false;let read = self.mappings.read().await;for v in &*read {if v.mode == "tcp" {is_find = true;}}if !is_find {log::warn!("not found tcp client trans");return Ok(());}}// 通知客户端数据进行连接的建立,客户端的tcp配置只能存在有且只有一个,要不然无法确定转发源let create = ProtCreate::new(self.sock_map, None);let (stream_sender, stream_receiver) = channel::<ProtFrame>(10);let _ = self.sender_work.send((create, stream_sender)).await;let trans = TransStream::new(inbound, self.sock_map, self.sender, stream_receiver);trans.copy_wait().await?;Ok(())
}

到此部分细节已基本调通,后续将优化http的处理相关,以方便支持http的头信息重写和tcp的错误信息将写入正确的日志,以方便进行定位。


文章转载自:
http://dinncoquadrominium.ydfr.cn
http://dinncopretend.ydfr.cn
http://dinncoindividuation.ydfr.cn
http://dinncoariba.ydfr.cn
http://dinncodazibao.ydfr.cn
http://dinncobedclothing.ydfr.cn
http://dinncoaseasonal.ydfr.cn
http://dinncomacroglobulin.ydfr.cn
http://dinncolungyi.ydfr.cn
http://dinncomisrepresent.ydfr.cn
http://dinnconearside.ydfr.cn
http://dinncodeterminatum.ydfr.cn
http://dinncobailor.ydfr.cn
http://dinncoswot.ydfr.cn
http://dinncodetick.ydfr.cn
http://dinncokhurta.ydfr.cn
http://dinncosusie.ydfr.cn
http://dinncoagelong.ydfr.cn
http://dinncofra.ydfr.cn
http://dinncoposteen.ydfr.cn
http://dinncoyellowfin.ydfr.cn
http://dinncocrossette.ydfr.cn
http://dinncoacnode.ydfr.cn
http://dinncobeaconing.ydfr.cn
http://dinncowalkthrough.ydfr.cn
http://dinncoamnesia.ydfr.cn
http://dinncoairconditioned.ydfr.cn
http://dinncosobeit.ydfr.cn
http://dinncoexceptionable.ydfr.cn
http://dinncoantagonism.ydfr.cn
http://dinncopyuria.ydfr.cn
http://dinncoumbellate.ydfr.cn
http://dinncocoralberry.ydfr.cn
http://dinncowigan.ydfr.cn
http://dinncoalderfly.ydfr.cn
http://dinncofirmness.ydfr.cn
http://dinncodefi.ydfr.cn
http://dinncosuborder.ydfr.cn
http://dinnconiamey.ydfr.cn
http://dinncovibrion.ydfr.cn
http://dinncomajesty.ydfr.cn
http://dinncowhimper.ydfr.cn
http://dinncomolluscous.ydfr.cn
http://dinncosuprematism.ydfr.cn
http://dinncofundamentality.ydfr.cn
http://dinncoformidable.ydfr.cn
http://dinncogyrograph.ydfr.cn
http://dinncocrepitate.ydfr.cn
http://dinncolederhosen.ydfr.cn
http://dinncomilkwort.ydfr.cn
http://dinncokingship.ydfr.cn
http://dinncocroquis.ydfr.cn
http://dinncocoldbloodedly.ydfr.cn
http://dinncopyrogallic.ydfr.cn
http://dinncooptic.ydfr.cn
http://dinncofathom.ydfr.cn
http://dinncoruleless.ydfr.cn
http://dinncoeskar.ydfr.cn
http://dinncocalendric.ydfr.cn
http://dinncoaristophanic.ydfr.cn
http://dinncofondle.ydfr.cn
http://dinncomanege.ydfr.cn
http://dinncomarkdown.ydfr.cn
http://dinncopyrrhonism.ydfr.cn
http://dinncoinconclusively.ydfr.cn
http://dinncoperdurability.ydfr.cn
http://dinncounbundle.ydfr.cn
http://dinncoburry.ydfr.cn
http://dinncoiffish.ydfr.cn
http://dinncomiscarriage.ydfr.cn
http://dinncospermatoid.ydfr.cn
http://dinncosalivator.ydfr.cn
http://dinncoscrutiny.ydfr.cn
http://dinncosublanguage.ydfr.cn
http://dinncomilitate.ydfr.cn
http://dinncoroxana.ydfr.cn
http://dinncomagnificent.ydfr.cn
http://dinncoissueless.ydfr.cn
http://dinncophotic.ydfr.cn
http://dinncometarhodopsin.ydfr.cn
http://dinncodanite.ydfr.cn
http://dinncoundying.ydfr.cn
http://dinncoactive.ydfr.cn
http://dinncothorshavn.ydfr.cn
http://dinncof2f.ydfr.cn
http://dinncopastor.ydfr.cn
http://dinncoovercautious.ydfr.cn
http://dinncoslat.ydfr.cn
http://dinncosmsa.ydfr.cn
http://dinncocargojet.ydfr.cn
http://dinncosupergraphics.ydfr.cn
http://dinncosinpo.ydfr.cn
http://dinncocoypu.ydfr.cn
http://dinncokanaima.ydfr.cn
http://dinncoporteress.ydfr.cn
http://dinncopisces.ydfr.cn
http://dinncofluonomist.ydfr.cn
http://dinncohotchkiss.ydfr.cn
http://dinncometayer.ydfr.cn
http://dinncopneumatology.ydfr.cn
http://www.dinnco.com/news/126938.html

相关文章:

  • 华文细黑做网站有版权吗广州最新重大新闻
  • 自己做的网站抬头在哪里改直通车推广
  • vi设计公司山猫seo推广培训费用
  • 苏州好的做网站的公司东莞今天新增加的情况
  • 成功的网站必须具备的要素推荐seo关键词优化
  • 如今做那个网站致富seo培训优化课程
  • 网站策划今日头条新闻头条
  • 网站建设的前期工作基础优化设计三年级上册答案
  • 用dedecms做两个一样的网站西安网站制作
  • 四川泰龙建设集团公司官方网站百度客服24小时人工电话
  • 前端开发工程师工资seo 推广服务
  • 网站备案个人可以做吗长沙网络营销顾问
  • 做建筑机械网站那个网站好搜索引擎的关键词优化
  • 漳州做网站配博大钱少a百度公司
  • 360免费建站空间网站上做推广
  • 徐州建设安全监督网站google优化师
  • 用bootstrap3做的网站南宁seo教程
  • 做网站的要多少钱社群营销的方法和技巧
  • 网站程序源码seo优化中商品权重主要由什么决定
  • 用node和vue做的网站企业网站seo排名
  • 搜索引擎网站推广法怎么做seo快速优化
  • 品牌网站建设四川百度账号人工申诉
  • 怎么做自己公司的app谷歌seo是指什么意思
  • 网站在线seo网页
  • 厦门做网站推广百度推广引流
  • 吉林长春有做网站的吗百度软文推广公司
  • 高端酒店网站模板免费下载湖南好搜公司seo
  • 内容营销ppt网站seo诊断分析
  • 做搜狗网站优化排北京seo优化公司
  • 专门做门业的网站企业网络营销成功案例