mirror of
https://github.com/qtgolang/SunnyNet.git
synced 2026-08-30 22:11:29 -07:00
2025-06-10
This commit is contained in:
@@ -256,6 +256,11 @@ func createLocalCert(Sunny *Sunny, cert *x509.Certificate, serverName, host stri
|
||||
var err error
|
||||
if cert != nil {
|
||||
not := time.Now().AddDate(0, 0, 365)
|
||||
if serverName == "" || serverName == "null" {
|
||||
mHost = host
|
||||
} else {
|
||||
mHost = serverName
|
||||
}
|
||||
certByte, priByte, er := generatePem(cert, mHost, parent, priv)
|
||||
if er == nil {
|
||||
certificate, er1 := tls.X509KeyPair(certByte, priByte)
|
||||
@@ -412,7 +417,11 @@ func GetIpAddressHost(proxy *SunnyProxy.Proxy, ipAddress string, outRouterIP *ne
|
||||
|
||||
var _GetIpCertError = fmt.Errorf("no success Get Certificate")
|
||||
|
||||
func generatePem(template *x509.Certificate, mHost string, parent *x509.Certificate, priv *rsa.PrivateKey) ([]byte, []byte, error) {
|
||||
func generatePem(template *x509.Certificate, host string, parent *x509.Certificate, priv *rsa.PrivateKey) ([]byte, []byte, error) {
|
||||
mHost, _, err := net.SplitHostPort(host)
|
||||
if err != nil {
|
||||
mHost = host
|
||||
}
|
||||
template1 := x509.Certificate{
|
||||
SerialNumber: template.SerialNumber, // 序列号,CA 颁发的唯一序列号,通常为随机生成
|
||||
Subject: template.Subject, // 证书主题,包含持有者的信息(国家、组织等)
|
||||
|
||||
@@ -579,7 +579,6 @@ func connectToTarget(s *proxyRequest, proxyTools *SunnyProxy.Proxy, outRouterIP
|
||||
ProxyHost = proxyTools.Host
|
||||
dial = proxyTools.Dial
|
||||
}
|
||||
|
||||
ip = dns.GetFirstIP(s.Target.Host, ProxyHost)
|
||||
if ip != nil {
|
||||
remoteAddr := SunnyProxy.FormatIP(ip, fmt.Sprintf("%d", s.Target.Port))
|
||||
@@ -823,7 +822,7 @@ func (s *proxyRequest) httpProcessing(aheadData []byte, Tag string) {
|
||||
h2, _ = s.RwObj.Peek(11 - len(aheadData))
|
||||
}
|
||||
hh = []byte(string(aheadData) + string(h2))
|
||||
|
||||
|
||||
if string(hh) == "PRI * HTTP/" {
|
||||
s.defaultScheme = "https"
|
||||
s.h2Request(aheadData)
|
||||
@@ -862,6 +861,23 @@ func (s *proxyRequest) httpProcessing(aheadData []byte, Tag string) {
|
||||
}
|
||||
}
|
||||
if isRules && Method != public.HttpMethodCONNECT {
|
||||
// 每次最多读取 64 字节
|
||||
tmpBuf := make([]byte, 64)
|
||||
for {
|
||||
// 检查是否还有缓冲数据
|
||||
if s.RwObj.Buffered() == 0 {
|
||||
break
|
||||
}
|
||||
// 设置 10 毫秒超时
|
||||
_ = s.RwObj.SetReadDeadline(time.Now().Add(10 * time.Millisecond))
|
||||
// 读取数据
|
||||
n, err := s.RwObj.Read(tmpBuf)
|
||||
if err != nil || n == 0 {
|
||||
break
|
||||
}
|
||||
// 写入缓冲区
|
||||
buff.Write(tmpBuf[:n])
|
||||
}
|
||||
_ = s.RwObj.SetReadDeadline(time.Time{})
|
||||
if s.Global.disableTCP {
|
||||
return
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const SunnyVersion = "2025-05-13"
|
||||
const SunnyVersion = "2025-06-10"
|
||||
const Information = `
|
||||
------------------------------------------------------
|
||||
欢迎使用 SunnyNet 网络中间件 - V` + SunnyVersion + `
|
||||
|
||||
Reference in New Issue
Block a user