mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
fix: update user-agent regex to use regexp2 and handle match errors
This commit is contained in:
parent
3c85d70e86
commit
fb0d56db68
@ -1,11 +1,11 @@
|
||||
63a160690ef8aaf5770c410ce8a421fd ./ua3f-0.5.0-386.tar.gz
|
||||
4cd727205aa52fd3606b42b60e9e0593 ./ua3f-0.5.0-amd64.tar.gz
|
||||
c4101e2605391754d52b38ceb8ceb1f5 ./ua3f-0.5.0-arm.tar.gz
|
||||
392aa3e532973dc0f2b4f87691dd5572 ./ua3f-0.5.0-arm64.tar.gz
|
||||
d5098bca9f040865d4076de2cc131e44 ./ua3f-0.5.0-armv7.tar.gz
|
||||
392aa3e532973dc0f2b4f87691dd5572 ./ua3f-0.5.0-armv8.tar.gz
|
||||
c0a6f242eff63595a8dc661de1e4390f ./ua3f-0.5.0-mips64.tar.gz
|
||||
a6f7c49f5437d601077856d15b9ba8e7 ./ua3f-0.5.0-mipsle-hardfloat.tar.gz
|
||||
6f966df9a8e5c74a81c3e75d1b06ad9d ./ua3f-0.5.0-mipsle-softfloat.tar.gz
|
||||
3f8974026e09b59d95ee21ed0a9db4b6 ./ua3f-0.5.0-mipsle.tar.gz
|
||||
c86d8d56781d9b5e94805ca76e232dda ./ua3f-0.5.0-riscv64.tar.gz
|
||||
40758678c03ace553b3c4d5690218c52 ./ua3f-0.5.1-386.tar.gz
|
||||
43b8ec1a2dd43c8e6d826b4f785fabc9 ./ua3f-0.5.1-amd64.tar.gz
|
||||
1ea04bd958de26947ddaf7f272fb5aff ./ua3f-0.5.1-arm.tar.gz
|
||||
5c87c290de8e40715bc8802d7c7f09d2 ./ua3f-0.5.1-arm64.tar.gz
|
||||
3fec71215b595a069c5e6c438178e355 ./ua3f-0.5.1-armv7.tar.gz
|
||||
5c87c290de8e40715bc8802d7c7f09d2 ./ua3f-0.5.1-armv8.tar.gz
|
||||
c2b0a620f66c6140b9c64667d6015709 ./ua3f-0.5.1-mips64.tar.gz
|
||||
d4e325e5d7ac0c64a8ef659d04ca3164 ./ua3f-0.5.1-mipsle-hardfloat.tar.gz
|
||||
df1295c649a05d2b32ecc18700ca8489 ./ua3f-0.5.1-mipsle-softfloat.tar.gz
|
||||
6528a2b69d3c67dc7606de15e293d06c ./ua3f-0.5.1-mipsle.tar.gz
|
||||
3b064e7e7f4a18ca0b4750d7988b8d11 ./ua3f-0.5.1-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.
Binary file not shown.
BIN
bin/ua3f-0.5.1-386.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-386.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-amd64.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-amd64.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-arm.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-arm.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-arm64.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-arm64.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-armv7.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-armv7.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-armv8.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-armv8.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-mips64.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-mips64.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-mipsle-hardfloat.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-mipsle-hardfloat.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-mipsle-softfloat.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-mipsle-softfloat.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-mipsle.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-mipsle.tar.gz
Normal file
Binary file not shown.
BIN
bin/ua3f-0.5.1-riscv64.tar.gz
Normal file
BIN
bin/ua3f-0.5.1-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.5.0"
|
||||
release_version="0.5.1"
|
||||
target=cmd/ua3f.go
|
||||
dist=./dist
|
||||
release_dir=./bin
|
||||
|
||||
14
cmd/ua3f.go
14
cmd/ua3f.go
@ -7,21 +7,21 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
"ua3f/http"
|
||||
"ua3f/log"
|
||||
|
||||
"github.com/dlclark/regexp2"
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var version = "0.5.0"
|
||||
var version = "0.5.1"
|
||||
var payloadByte []byte
|
||||
var uaPattern string
|
||||
var uaRegexp *regexp.Regexp
|
||||
var uaRegexp *regexp2.Regexp
|
||||
var cache *expirable.LRU[string, string]
|
||||
var HTTP_METHOD = []string{"GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS", "TRACE", "CONNECT"}
|
||||
var whitelist = []string{
|
||||
@ -77,7 +77,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
logrus.Info(fmt.Sprintf("Listen on %s:%d", addr, port))
|
||||
uaRegexp, err = regexp.Compile(uaPattern)
|
||||
uaRegexp, err = regexp2.Compile(uaPattern, regexp2.None)
|
||||
if err != nil {
|
||||
logrus.Fatal("Invalid User-Agent Regex Pattern: ", err)
|
||||
return
|
||||
@ -440,7 +440,11 @@ func CopyPileline(dst io.Writer, src io.Reader, destAddrPort string) {
|
||||
isInWhiteList := false
|
||||
isMatchUaPattern := true
|
||||
if uaPattern != "" {
|
||||
isMatchUaPattern = uaRegexp.MatchString(uaStr)
|
||||
isMatchUaPattern, err = uaRegexp.MatchString(uaStr)
|
||||
if err != nil {
|
||||
logrus.Error(fmt.Sprintf("[%s][%s] User-Agent Regex Pattern Match Error: %s", destAddrPort, src.(*net.TCPConn).RemoteAddr().String(), err.Error()))
|
||||
isMatchUaPattern = true
|
||||
}
|
||||
}
|
||||
if slices.Contains(whitelist, uaStr) {
|
||||
isInWhiteList = true
|
||||
|
||||
BIN
dist/ua3f_0.5.0-1_386.ipk
vendored
BIN
dist/ua3f_0.5.0-1_386.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_amd64.ipk
vendored
BIN
dist/ua3f_0.5.0-1_amd64.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_arm.ipk
vendored
BIN
dist/ua3f_0.5.0-1_arm.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_arm64.ipk
vendored
BIN
dist/ua3f_0.5.0-1_arm64.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_armv7.ipk
vendored
BIN
dist/ua3f_0.5.0-1_armv7.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_armv8.ipk
vendored
BIN
dist/ua3f_0.5.0-1_armv8.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_mips64.ipk
vendored
BIN
dist/ua3f_0.5.0-1_mips64.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_mipsle-hardfloat.ipk
vendored
BIN
dist/ua3f_0.5.0-1_mipsle-hardfloat.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_mipsle-softfloat.ipk
vendored
BIN
dist/ua3f_0.5.0-1_mipsle-softfloat.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_mipsle.ipk
vendored
BIN
dist/ua3f_0.5.0-1_mipsle.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.0-1_riscv64.ipk
vendored
BIN
dist/ua3f_0.5.0-1_riscv64.ipk
vendored
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_386.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_386.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_amd64.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_amd64.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_arm.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_arm.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_arm64.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_arm64.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_armv7.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_armv7.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_armv8.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_armv8.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_mips64.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_mips64.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_mipsle-hardfloat.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_mipsle-hardfloat.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_mipsle-softfloat.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_mipsle-softfloat.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_mipsle.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_mipsle.ipk
vendored
Normal file
Binary file not shown.
BIN
dist/ua3f_0.5.1-1_riscv64.ipk
vendored
Normal file
BIN
dist/ua3f_0.5.1-1_riscv64.ipk
vendored
Normal file
Binary file not shown.
1
go.mod
1
go.mod
@ -8,6 +8,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||
github.com/stretchr/testify v1.8.2 // indirect
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
)
|
||||
|
||||
4
go.sum
4
go.sum
@ -1,6 +1,8 @@
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
|
||||
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@ -9,7 +11,7 @@ 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/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/objx v0.5.1/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=
|
||||
|
||||
@ -20,7 +20,7 @@ ckcmd() {
|
||||
cd /root
|
||||
getcpucore
|
||||
|
||||
version=0.5.0
|
||||
version=0.5.1
|
||||
ua3f_tar=ua3f-$version-$cpucore.tar.gz
|
||||
|
||||
if id -u shellclash >/dev/null 2>&1; then
|
||||
|
||||
@ -3,7 +3,7 @@ local uci = require("luci.model.uci").cursor()
|
||||
ua3f = Map("ua3f",
|
||||
"UA3F",
|
||||
[[
|
||||
<a href="https://github.com/SunBK201/UA3F" target="_blank">Version: 0.5.0</a>
|
||||
<a href="https://github.com/SunBK201/UA3F" target="_blank">Version: 0.5.1</a>
|
||||
<br>
|
||||
Across the Campus we can reach every corner in the world.
|
||||
]]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
Package: ua3f
|
||||
Version: 0.5.0-1
|
||||
Version: 0.5.1-1
|
||||
Depends: libc, luci-compat
|
||||
Source: /feed/openwrt
|
||||
SourceName: UA3F
|
||||
@ -7,5 +7,5 @@ License: GPL-3.0-only
|
||||
Section: net
|
||||
SourceDateEpoch: 1711267200
|
||||
Architecture: all
|
||||
Installed-Size: 2641920
|
||||
Installed-Size: 2775040
|
||||
Description: Implementation of the new generation of HTTP User-Agent modification methodology.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
Package: ua3f
|
||||
Version: 0.5.0-1
|
||||
Version: 0.5.1-1
|
||||
Depends: libc, luci-compat
|
||||
Source: /feed/openwrt
|
||||
SourceName: UA3F
|
||||
@ -7,5 +7,5 @@ License: GPL-3.0-only
|
||||
Section: net
|
||||
SourceDateEpoch: 1711267200
|
||||
Architecture: all
|
||||
Installed-Size: 2641920
|
||||
Installed-Size: 2703360
|
||||
Description: Implementation of the new generation of HTTP User-Agent modification methodology.
|
||||
|
||||
Binary file not shown.
@ -3,7 +3,7 @@ local uci = require("luci.model.uci").cursor()
|
||||
ua3f = Map("ua3f",
|
||||
"UA3F",
|
||||
[[
|
||||
<a href="https://github.com/SunBK201/UA3F" target="_blank">Version: 0.5.0</a>
|
||||
<a href="https://github.com/SunBK201/UA3F" target="_blank">Version: 0.5.1</a>
|
||||
<br>
|
||||
Across the Campus we can reach every corner in the world.
|
||||
]]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user