LittleProxy 系列[1]之整体结构分析
2019-08-05 10:35:00 0 举报
LittleProxy 源码分析
作者其他创作
大纲/内容
图例
B1: 处理左边client来的消息B6: 处理来自右边server的消息
HttpProxyServer start();
用户扩展域
ProxyToServerConnection currentServerConnection;
A4: 创建代理 server
HttpFiltersAdapter
bytesWrittenMonitor
TCP
B5.2: 初始化 Flow
channelRegistered();
write()
ProxyToServerConnection
registerProxyServer(HttpProxyServer proxyServer);
HttpFilters
B2: 状态机
initChannelPipeline();
idle
encoder
B5.3: 启动 Flow
doReadHTTPInitial();
pipeline
initChannelPipeline():client到 proxy 的 handler在这里被添加.
doStart():这里是标准的基于ServerBootstrap启动netty server的实现.
respond();
ClientToProxyConnection
HttpFiltersSourceAdapter
readHTTPInitial();
左侧 线程组
DefaultHttpProxyServer
start();
HttpFilters filterRequest();
requestReadMonitor
A6: 创建 server
DefaultHttpProxyServerBootstrap(Properties props);
初始化右侧链接 pipeline
connectAndWrite();
ProxyThreadPools
create();
NioEventLoopGroup proxyToServerWorkerPool;
B5: 调用 write
channelInactive();
B3: do
bytesReadMonitor
readHTTP();
A8: 初始化左侧链接pipeline
A3: 创建 ServerGroup
A5: 关联 server 和线程组(serverGroup)
Queue<ConnectionFlowStep> steps;
B4: 建立到 server 的链接
succeed();
create
A1:创建bootStrap
decoder
NioEventLoopGroup clientToProxyAcceptorPool;
DefaultHttpProxyServerBootstrap
B7: 把返回结果传给左侧链路
UDT
channelActive();
B5.1: 建立链接
add
Launcher
readHTTPInitial();1. 鉴权; 2. 进入 do 方法
线程是系统的发动机
stop();
A7:注册 handler
右侧 线程组
main()
start(): build().start();
NioEventLoopGroup clientToProxyWorkerPool;
responseWrittenMonitor
B0: 收到client的消息
List<HttpProxyServer> registeredServers;
HttpProxyServerBootstrap
ServerGroup
B5.2.1:\b每个阶段封装一个 step
ConnectionFlow
currentServerConnection;
start()
HttpFiltersSource
final channelRead0();
LittleProxy 源码分析: 整体结构
A2: start()
HttpProxyServer
read(Object msg);
ProxyConnection extends SimpleChannelInboundHandler
initializeConnectionFlow
ChannelGroup allChannels;
serverGroup;
0 条评论
回复 删除
下一页