mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-02 11:50:28 +08:00
编译脚本支持GCC
This commit is contained in:
@@ -53,7 +53,7 @@ function build() {
|
|||||||
|
|
||||||
# generate files
|
# generate files
|
||||||
echo "generating files ..."
|
echo "generating files ..."
|
||||||
go run -tags $TAG "$ROOT"/../cmd/edge-admin/main.go generate
|
env CGO_ENABLED=0 go run -tags $TAG "$ROOT"/../cmd/edge-admin/main.go generate
|
||||||
if [ "$(which uglifyjs)" ]; then
|
if [ "$(which uglifyjs)" ]; then
|
||||||
echo "compress to component.js ..."
|
echo "compress to component.js ..."
|
||||||
uglifyjs --compress --mangle -- "${JS_ROOT}"/components.src.js > "${JS_ROOT}"/components.js
|
uglifyjs --compress --mangle -- "${JS_ROOT}"/components.src.js > "${JS_ROOT}"/components.js
|
||||||
@@ -99,11 +99,34 @@ function build() {
|
|||||||
rm -f "$(basename "$EDGE_API_ZIP_FILE")"
|
rm -f "$(basename "$EDGE_API_ZIP_FILE")"
|
||||||
cd - || exit
|
cd - || exit
|
||||||
|
|
||||||
|
# find gcc
|
||||||
|
GCC_DIR=""
|
||||||
|
CC_PATH=""
|
||||||
|
CXX_PATH=""
|
||||||
|
if [ "${ARCH}" == "amd64" ]; then
|
||||||
|
GCC_DIR="/usr/local/gcc/x86_64-unknown-linux-gnu/bin"
|
||||||
|
CC_PATH="x86_64-unknown-linux-gnu-gcc"
|
||||||
|
CXX_PATH="x86_64-unknown-linux-gnu-g++"
|
||||||
|
fi
|
||||||
|
if [ "${ARCH}" == "arm64" ]; then
|
||||||
|
GCC_DIR="/usr/local/gcc/aarch64-unknown-linux-gnu/bin"
|
||||||
|
CC_PATH="aarch64-unknown-linux-gnu-gcc"
|
||||||
|
CXX_PATH="aarch64-unknown-linux-gnu-g++"
|
||||||
|
fi
|
||||||
|
|
||||||
# build
|
# build
|
||||||
echo "building ${NAME} ..."
|
echo "building ${NAME} ..."
|
||||||
env GOOS="$OS" GOARCH="$ARCH" go build -trimpath -tags $TAG -ldflags="-s -w" -o "$DIST"/bin/${NAME} "$ROOT"/../cmd/edge-admin/main.go
|
if [ -f "${GCC_DIR}/${CC_PATH}" ]; then
|
||||||
|
echo " building ${NAME} with gcc ..."
|
||||||
|
env CC="${GCC_DIR}/${CC_PATH}" \
|
||||||
|
CXX="${GCC_DIR}/${CXX_PATH}" \
|
||||||
|
CGO_ENABLED=1 \
|
||||||
|
GOOS="$OS" GOARCH="$ARCH" go build -trimpath -tags "${TAG} gcc" -ldflags="-s -w" -o "$DIST"/bin/${NAME} "$ROOT"/../cmd/edge-admin/main.go
|
||||||
|
else
|
||||||
|
GOOS="$OS" GOARCH="$ARCH" go build -trimpath -tags $TAG -ldflags="-s -w" -o "$DIST"/bin/${NAME} "$ROOT"/../cmd/edge-admin/main.go
|
||||||
|
fi
|
||||||
if [ ! -f "${DIST}/bin/${NAME}" ]; then
|
if [ ! -f "${DIST}/bin/${NAME}" ]; then
|
||||||
echo "build failed!"
|
echo "build '${NAME}' failed!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
JS_ROOT=../web/public/js
|
JS_ROOT=../web/public/js
|
||||||
|
|
||||||
echo "generating component.src.js ..."
|
echo "generating component.src.js ..."
|
||||||
go run -tags=community ../cmd/edge-admin/main.go generate
|
env CGO_ENABLED=0 go run -tags=community ../cmd/edge-admin/main.go generate
|
||||||
|
|
||||||
if [ "$(which uglifyjs)" ]; then
|
if [ "$(which uglifyjs)" ]; then
|
||||||
echo "compress to component.js ..."
|
echo "compress to component.js ..."
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build gcc
|
||||||
|
|
||||||
package injectionutils
|
package injectionutils
|
||||||
|
|
||||||
|
|||||||
21
internal/waf/injectionutils/utils_sqli_stub.go
Normal file
21
internal/waf/injectionutils/utils_sqli_stub.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build !gcc
|
||||||
|
|
||||||
|
package injectionutils
|
||||||
|
|
||||||
|
// DetectSQLInjectionCache detect sql injection in string with cache
|
||||||
|
func DetectSQLInjectionCache(input string, isStrict bool, cacheLife int) bool {
|
||||||
|
// stub
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// DetectSQLInjection detect sql injection in string
|
||||||
|
func DetectSQLInjection(input string, isStrict bool) bool {
|
||||||
|
// stub
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func detectSQLInjectionOne(input string) bool {
|
||||||
|
// stub
|
||||||
|
return false
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build gcc
|
||||||
|
|
||||||
package injectionutils_test
|
package injectionutils_test
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build gcc
|
||||||
|
|
||||||
package injectionutils
|
package injectionutils
|
||||||
|
|
||||||
|
|||||||
22
internal/waf/injectionutils/utils_xss_stub.go
Normal file
22
internal/waf/injectionutils/utils_xss_stub.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build !gcc
|
||||||
|
|
||||||
|
package injectionutils
|
||||||
|
|
||||||
|
const MaxCacheDataSize = 1 << 20
|
||||||
|
|
||||||
|
func DetectXSSCache(input string, isStrict bool, cacheLife int) bool {
|
||||||
|
// stub
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// DetectXSS detect XSS in string
|
||||||
|
func DetectXSS(input string, isStrict bool) bool {
|
||||||
|
// stub
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func detectXSSOne(input string, isStrict bool) bool {
|
||||||
|
// stub
|
||||||
|
return false
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build gcc
|
||||||
|
|
||||||
package injectionutils_test
|
package injectionutils_test
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user