Giter Site home page Giter Site logo

sunnynet's Introduction

Sunny网络中间件


Sunny网络中间件 和 Fiddler 类似。 是可跨平台的网络分析组件

可用于HTTP/HTTPS/WS/WSS/TCP/UDP网络分析 为二次开发量身制作

支持 获取/修改 HTTP/HTTPS/WS/WSS/TCP/TLS-TCP/UDP 发送及返回数据

支持 对 HTTP/HTTPS/WS/WSS 指定连接使用指定代理

支持 对 HTTP/HTTPS/WS/WSS/TCP/TLS-TCP 链接重定向

支持 gzip, deflate, br 解码

支持 WS/WSS/TCP/TLS-TCP/UDP 主动发送数据

  • 由于代码主要是做DLL使用,部分功能未封装给Go使用(例如添加证书,添加证书使用规则),请自行探索!

BUG 反馈

QQ群:751406884

二群:545120699


示例文件以及抓包工具 下载地址

密码:ca5l


  • GoLang使用示例代码

package main

import (
	"fmt"
	"github.com/qtgolang/SunnyNet/SunnyNet"
	"github.com/qtgolang/SunnyNet/public"
	"time"
)

var Sunny = SunnyNet.NewSunny()

func main() {
	//绑定回调函数
	Sunny.SetGoCallback(HttpCallback, TcpCallback, WSCallback, UdpCallback)

	//绑定端口号并启动
	Sunny.SetPort(2023).Start()

	//避免程序退出
	time.Sleep(24 * time.Hour)
}
func HttpCallback(Conn *SunnyNet.HttpConn) {
	if Conn.Type == public.HttpSendRequest {
		//发起请求
		//这里可以对请求数据修改
		if Conn.Request.Body != nil {
			Body, _ := io.ReadAll(Conn.Request.Body)
			_ = Conn.Request.Body.Close()

			//这里可以对Body修改

			Body = []byte("Hello Sunny Request")

			Conn.Request.Body = io.NopCloser(bytes.NewBuffer(Body))

			//直接响应,不让其发送请求
			//Conn.StopRequest(200, "Hello Word")
		}
		fmt.Println(Conn.Request.URL.String())
	} else if Conn.Type == public.HttpResponseOK {
		//请求完成
		if Conn.Response.Body != nil {
			Body, _ := io.ReadAll(Conn.Response.Body)
			_ = Conn.Response.Body.Close()

			//这里可以对Body修改

			Body = []byte("Hello Sunny Response")

			Conn.Response.Body = io.NopCloser(bytes.NewBuffer(Body))
		}

	} else if Conn.Type == public.HttpRequestFail {
		//请求错误
	}
}
func WSCallback(Conn *SunnyNet.WsConn) {
	//捕获到数据可以修改,修改空数据,取消发送/接收
	fmt.Println(Conn.Url)
}
func TcpCallback(Conn *SunnyNet.TcpConn) {
	//捕获到数据可以修改,修改空数据,取消发送/接收
	
	fmt.Println(Conn.Pid, Conn.LocalAddr, Conn.RemoteAddr, Conn.Type, Conn.GetBodyLen())
}
func UdpCallback(Conn *SunnyNet.UDPConn) {
	//在 Windows 捕获UDP需要加载驱动,并且设置进程名
	//其他情况需要设置Socket5代理,才能捕获到UDP
	//捕获到数据可以修改,修改空数据,取消发送/接收
	if public.SunnyNetUDPTypeReceive == Conn.Type {
		fmt.Println("接收UDP", Conn.LocalAddress, Conn.RemoteAddress, len(Conn.Data))
	}
	if public.SunnyNetUDPTypeSend == Conn.Type {
		fmt.Println("发送UDP", Conn.LocalAddress, Conn.RemoteAddress, len(Conn.Data))
	}
	if public.SunnyNetUDPTypeClosed == Conn.Type {
		fmt.Println("关闭UDP", Conn.LocalAddress, Conn.RemoteAddress)
	}
}

sunnynet's People

Contributors

qtgolang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.