有两个文章 可以看一下。
https://www.cnblogs.com/sepeng/p/5121993.html
http://blog.sina.com.cn/s/blog_a73f94190102wrjs.html
封装成IP好些。