mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
feat: pass unimportant ua
This commit is contained in:
parent
b4064d1fb7
commit
2cb6f3d358
@ -1,10 +1,10 @@
|
||||
69348631c2d1bf17768dcbeac972b63f ./ua3f-0.1.2-386.tar.gz
|
||||
06b14787b948906ce42372ab656d2078 ./ua3f-0.1.2-amd64.tar.gz
|
||||
b53f3b49d42b4d93800e4665e525f26c ./ua3f-0.1.2-arm.tar.gz
|
||||
3497c75d7f53085b8d34d148059831f8 ./ua3f-0.1.2-arm64.tar.gz
|
||||
3497c75d7f53085b8d34d148059831f8 ./ua3f-0.1.2-armv8.tar.gz
|
||||
7a19c7e1539294b2fe18244bab9ad12e ./ua3f-0.1.2-mips64.tar.gz
|
||||
8034fb13e48c836793dfbc3f1d213c2f ./ua3f-0.1.2-mipsle-hardfloat.tar.gz
|
||||
b386e9b12c94413f53bdf7e8bcc232d7 ./ua3f-0.1.2-mipsle-softfloat.tar.gz
|
||||
8034fb13e48c836793dfbc3f1d213c2f ./ua3f-0.1.2-mipsle.tar.gz
|
||||
5f6870e9f7b8d4c0e4ffc56eff1c37d4 ./ua3f-0.1.2-riscv64.tar.gz
|
||||
0b42820902e22e3755da79ba4fd0e80a ./ua3f-0.1.3-386.tar.gz
|
||||
815742dc4d709189e34ca0d78958d5a0 ./ua3f-0.1.3-amd64.tar.gz
|
||||
b264ef121d1b85551f82c2d68e2714f7 ./ua3f-0.1.3-arm.tar.gz
|
||||
c914a83a360b252baf3b68d4c7b449cf ./ua3f-0.1.3-arm64.tar.gz
|
||||
c914a83a360b252baf3b68d4c7b449cf ./ua3f-0.1.3-armv8.tar.gz
|
||||
dc058a007d193112dc4dbcfead696b88 ./ua3f-0.1.3-mips64.tar.gz
|
||||
143bd83ee2e17c1c7f016009ffc64388 ./ua3f-0.1.3-mipsle-hardfloat.tar.gz
|
||||
056438deda501f64661d5745a2ba9a64 ./ua3f-0.1.3-mipsle-softfloat.tar.gz
|
||||
e98ad16bdc00147454014ad77464587b ./ua3f-0.1.3-mipsle.tar.gz
|
||||
78f09a5a575264bdbd203732902069b3 ./ua3f-0.1.3-riscv64.tar.gz
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/ua3f-0.1.3-386.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-386.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-amd64.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-amd64.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-arm.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-arm.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-arm64.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-arm64.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-armv8.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-armv8.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-mips64.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-mips64.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-mipsle-hardfloat.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-mipsle-hardfloat.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-mipsle-softfloat.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-mipsle-softfloat.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-mipsle.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-mipsle.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.1.3-riscv64.tar.gz
Normal file
BIN
bin/ua3f-0.1.3-riscv64.tar.gz
Normal file
Binary file not shown.
2
build.sh
2
build.sh
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
project_name="ua3f"
|
||||
release_version="0.1.2"
|
||||
release_version="0.1.3"
|
||||
target=cmd/ua3f.go
|
||||
|
||||
release_dir=./bin
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
---
|
||||
#--------------------------------------------------------------------------------------#
|
||||
# Written by SunBK201
|
||||
# https://github.com/SunBK201/MyProfiles
|
||||
# https://github.com/SunBK201/UA3F
|
||||
#--------------------------------------------------------------------------------------#
|
||||
# Port of HTTP(S) proxy server on the local end
|
||||
port: 7890
|
||||
|
||||
75
cmd/ua3f.go
75
cmd/ua3f.go
@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
"ua3f/http"
|
||||
@ -16,12 +17,26 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var version = "0.1.2"
|
||||
var version = "0.1.3"
|
||||
var payloadByte []byte
|
||||
var cache *expirable.LRU[string, string]
|
||||
|
||||
func main() {
|
||||
var whitelist = []string{
|
||||
"MicroMessenger Client",
|
||||
"ByteDancePcdn",
|
||||
"Go-http-client/1.1",
|
||||
}
|
||||
|
||||
// var dpool *ants.PoolWithFunc
|
||||
// var gpool *ants.PoolWithFunc
|
||||
//
|
||||
// type RelayConn struct {
|
||||
// src net.Conn
|
||||
// dst net.Conn
|
||||
// destAddrPort string
|
||||
// }
|
||||
|
||||
func main() {
|
||||
var payload string
|
||||
var addr string
|
||||
var port int
|
||||
@ -40,7 +55,12 @@ func main() {
|
||||
logrus.Info(fmt.Sprintf("User-Agent: %s", payload))
|
||||
logrus.Info(fmt.Sprintf("Log level: %s", loglevel))
|
||||
|
||||
cache = expirable.NewLRU[string, string](100, nil, time.Second*600)
|
||||
cache = expirable.NewLRU[string, string](300, nil, time.Second*600)
|
||||
|
||||
// dpool, _ = ants.NewPoolWithFunc(1000, forward)
|
||||
// gpool, _ = ants.NewPoolWithFunc(500, gforward)
|
||||
// defer dpool.Release()
|
||||
// defer gpool.Release()
|
||||
|
||||
payloadByte = []byte(payload)
|
||||
|
||||
@ -74,6 +94,7 @@ func process(client net.Conn) {
|
||||
return
|
||||
}
|
||||
Socks5Forward(client, target, destAddrPort)
|
||||
// Socks5Relay(client, target, destAddrPort)
|
||||
}
|
||||
|
||||
func Socks5Auth(client net.Conn) (err error) {
|
||||
@ -151,6 +172,39 @@ func Socks5Connect(client net.Conn) (net.Conn, string, error) {
|
||||
return dest, destAddrPort, nil
|
||||
}
|
||||
|
||||
/*
|
||||
func forward(i interface{}) {
|
||||
rc := i.(*RelayConn)
|
||||
defer rc.src.Close()
|
||||
defer rc.dst.Close()
|
||||
io.Copy(rc.src, rc.dst)
|
||||
}
|
||||
|
||||
func gforward(i interface{}) {
|
||||
rc := i.(*RelayConn)
|
||||
defer rc.dst.Close()
|
||||
defer rc.src.Close()
|
||||
CopyPileline(rc.dst, rc.src, rc.destAddrPort)
|
||||
}
|
||||
|
||||
func Socks5Relay(client, target net.Conn, destAddrPort string) {
|
||||
rc := &RelayConn{
|
||||
src: client,
|
||||
dst: target,
|
||||
destAddrPort: destAddrPort,
|
||||
}
|
||||
logrus.Debug(fmt.Sprintf("dpool: %d left: %d, gpool: %d left: %d", dpool.Running(), dpool.Free(), gpool.Running(), gpool.Free()))
|
||||
dpool.Invoke(rc)
|
||||
if cache.Contains(destAddrPort) {
|
||||
logrus.Debug(fmt.Sprintf("Hit LRU Relay Cache: %s", destAddrPort))
|
||||
rc.src, rc.dst = rc.dst, rc.src
|
||||
dpool.Invoke(rc)
|
||||
} else {
|
||||
gpool.Invoke(rc)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func Socks5Forward(client, target net.Conn, destAddrPort string) {
|
||||
forward := func(src, dest net.Conn) {
|
||||
defer src.Close()
|
||||
@ -168,9 +222,9 @@ func Socks5Forward(client, target net.Conn, destAddrPort string) {
|
||||
if cache.Contains(destAddrPort) {
|
||||
logrus.Debug(fmt.Sprintf("Hit LRU Relay Cache: %s", destAddrPort))
|
||||
go forward(target, client)
|
||||
return
|
||||
} else {
|
||||
go gforward(target, client)
|
||||
}
|
||||
go gforward(target, client)
|
||||
}
|
||||
|
||||
func CopyPileline(dst io.Writer, src io.Reader, destAddrPort string) {
|
||||
@ -203,7 +257,7 @@ func CopyPileline(dst io.Writer, src io.Reader, destAddrPort string) {
|
||||
dst.Write(buf[0:nr])
|
||||
io.Copy(dst, src)
|
||||
cache.Add(destAddrPort, destAddrPort)
|
||||
logrus.Debug(fmt.Sprintf("Not HTTP, Hint: %v, Add LRU Relay Cache: %s", buf[0:7], destAddrPort))
|
||||
logrus.Debug(fmt.Sprintf("Not HTTP, Hint: %v, Add LRU Relay Cache: %s, Cache Len: %d", buf[0:7], destAddrPort, cache.Len()))
|
||||
return
|
||||
}
|
||||
for {
|
||||
@ -221,6 +275,13 @@ func CopyPileline(dst io.Writer, src io.Reader, destAddrPort string) {
|
||||
}
|
||||
value, start, end := parser.FindHeader([]byte("User-Agent"))
|
||||
if value != nil && end > start {
|
||||
if slices.Contains(whitelist, string(value)) {
|
||||
logrus.Debug(fmt.Sprintf("[%s][%s] Hit User-Agent Whitelist: %s, Add LRU Relay Cache, Cache Len: %d", destAddrPort, src.(*net.TCPConn).RemoteAddr().String(), string(value), cache.Len()))
|
||||
dst.Write(buf[0:nr])
|
||||
io.Copy(dst, src)
|
||||
cache.Add(destAddrPort, destAddrPort)
|
||||
return
|
||||
}
|
||||
logrus.Debug(fmt.Sprintf("[%s][%s] Hit User-Agent: %s", destAddrPort, src.(*net.TCPConn).RemoteAddr().String(), string(value)))
|
||||
for i := start; i < end; i++ {
|
||||
buf[i] = 32
|
||||
@ -232,7 +293,7 @@ func CopyPileline(dst io.Writer, src io.Reader, destAddrPort string) {
|
||||
buf[start+i] = payloadByte[i]
|
||||
}
|
||||
} else {
|
||||
logrus.Debug(fmt.Sprintf("[%s] Not found User-Agent, Add LRU Relay Cache", destAddrPort))
|
||||
logrus.Debug(fmt.Sprintf("[%s] Not found User-Agent, Add LRU Relay Cache, Cache Len: %d", destAddrPort, cache.Len()))
|
||||
dst.Write(buf[0:nr])
|
||||
io.Copy(dst, src)
|
||||
cache.Add(destAddrPort, destAddrPort)
|
||||
|
||||
5
go.mod
5
go.mod
@ -7,4 +7,7 @@ require (
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
)
|
||||
|
||||
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
require (
|
||||
github.com/stretchr/testify v1.8.2 // indirect
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
)
|
||||
|
||||
10
go.sum
10
go.sum
@ -8,10 +8,16 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@ -16,7 +16,7 @@ getcpucore() {
|
||||
cd /root
|
||||
getcpucore
|
||||
|
||||
version=0.1.2
|
||||
version=0.1.3
|
||||
ua3f_tar=ua3f-$version-$cpucore.tar.gz
|
||||
|
||||
if id -u shellclash &> /dev/null; then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user