优化项目结构

This commit is contained in:
2025-02-27 18:07:00 +08:00
parent a541a7bd3a
commit 38d5341e84
9 changed files with 176 additions and 36 deletions

57
server/fwd/analysis.go Normal file
View File

@@ -0,0 +1,57 @@
package fwd
import (
"bufio"
"io"
"log/slog"
"proxy-server/pkg/utils"
)
func analysis(reader io.Reader) {
buf := bufio.NewReader(reader)
first, err := buf.Peek(8)
if err != nil {
slog.Error("analysis peek error", "err", err)
} else {
switch {
case first[0] == 0x16:
analysisHttps(reader)
case
string(first[:4]) == "GET ",
// string(first[:4]) == "PUT ",
string(first[:5]) == "POST ":
// string(first[:4]) == "HEAD ",
// string(first[:4]) == "TRACE ",
// string(first[:4]) == "PATCH ",
// string(first[:4]) == "DELETE ",
// string(first[:4]) == "CONNECT ",
// string(first[:4]) == "OPTIONS ":
analysisHttp(reader)
}
}
discord(reader)
}
func analysisHttp(reader io.Reader) {
}
func analysisHttps(reader io.Reader) {
head, err := utils.ReadBuffer(reader, 5)
if err != nil {
slog.Error("analysis https err", "err", err)
return
}
if head[1] == 0x03 && head[2] == 0x03 {
// tls1.2
}
}
func discord(reader io.Reader) {
_, err := io.Copy(io.Discard, reader)
if err != nil {
slog.Error("analysis discord err", "err", err)
}
}