mirror of
https://github.com/unchainese/unchain.git
synced 2025-12-24 12:38:02 +08:00
simplify
This commit is contained in:
2
.github/workflows/deploy.sh
vendored
2
.github/workflows/deploy.sh
vendored
@@ -3,7 +3,7 @@
|
||||
echo "$SSH_KEY" > key.pem
|
||||
chmod 600 key.pem
|
||||
|
||||
scp -o StrictHostKeyChecking=no -i key.pem cmd/node/unchain cmd/node/unchain.service $SSH_USER@$SSH_HOST:~
|
||||
scp -o StrictHostKeyChecking=no -i key.pem unchain unchain.service $SSH_USER@$SSH_HOST:~
|
||||
ssh -o StrictHostKeyChecking=no -i key.pem $SSH_USER@$SSH_HOST << EOF
|
||||
cd ~ && pwd
|
||||
sudo rm -rf /app && sudo mkdir /app
|
||||
|
||||
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
@@ -41,7 +41,7 @@ jobs:
|
||||
GIT_REPO: ${{ github.repository }}
|
||||
run: |
|
||||
echo "Building Go application with gitHash=${{ env.gitHash }} and buildTime=${{ env.buildTime }}"
|
||||
go build -ldflags="-X 'github.com/unchainese/unchain/internal/global.gitHash=${{ github.sha }}' -X 'github.com/unchainese/unchain/internal/global.buildTime=${{ env.buildTime }}'" -o cmd/node/unchain cmd/node/main.go
|
||||
go build -ldflags="-X 'github.com/unchainese/unchain/internal/global.gitHash=${{ github.sha }}' -X 'github.com/unchainese/unchain/internal/global.buildTime=${{ env.buildTime }}'" -o unchain main.go
|
||||
|
||||
- name: Deploy to AWS EC2
|
||||
env:
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.idea
|
||||
*.log
|
||||
*.log
|
||||
*.exe
|
||||
@@ -14,17 +14,28 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
SubAddresses string `desc:"sub addresses" def:"node1.xxx.cn:80,node2.xxx.cn:443"` //这个信息会帮助你生成V2ray/Clash/ShadowRocket的订阅链接,同时这个是互联网浏览器访问的地址
|
||||
Port string `desc:"port" def:"8080"` //golang app 服务端口
|
||||
RegisterUrl string `desc:"register url" def:"https://admin.unchain.people.from.censorship"` //optional,流量,用户鉴权的主控服务器地址
|
||||
RegisterToken string `desc:"register token" def:"unchain people from censorship and surveillance"` //optional,流量,用户鉴权的主控服务器token
|
||||
AllowUsers string `desc:"allow users UUID" def:"903bcd04-79e7-429c-bf0c-0456c7de9cdc,903bcd04-79e7-429c-bf0c-0456c7de9cd1"` //单机模式下,允许的用户UUID
|
||||
LogFile string `desc:"log file path" def:""` //日志文件路径
|
||||
DebugLevel string `desc:"debug level" def:"DEBUG"` //日志级别
|
||||
IntervalSecond string `desc:"interval second" def:"360"` //seconds 向主控服务器推送,流量使用情况的间隔时间
|
||||
GitHash string `desc:"git hash" def:""` //optional git hash
|
||||
BuildTime string `desc:"build time" def:""` //optional build time
|
||||
RunAt string `desc:"run at" def:""` //optional run at
|
||||
SubAddresses string `desc:"sub addresses" def:"node1.xxx.cn:80,node2.xxx.cn:443"` //这个信息会帮助你生成V2ray/Clash/ShadowRocket的订阅链接,同时这个是互联网浏览器访问的地址
|
||||
Port string `desc:"port" def:"8080"` //golang app 服务端口
|
||||
RegisterUrl string `desc:"register url" def:"https://admin.unchain.people.from.censorship"` //optional,流量,用户鉴权的主控服务器地址
|
||||
RegisterToken string `desc:"register token" def:"unchain people from censorship and surveillance"` //optional,流量,用户鉴权的主控服务器token
|
||||
AllowUsers string `desc:"allow users UUID" def:"903bcd04-79e7-429c-bf0c-0456c7de9cdc,903bcd04-79e7-429c-bf0c-0456c7de9cd1"` //单机模式下,允许的用户UUID
|
||||
LogFile string `desc:"log file path" def:""` //日志文件路径
|
||||
DebugLevel string `desc:"debug level" def:"DEBUG"` //日志级别
|
||||
IntervalSecond string `desc:"interval second" def:"360"` //seconds 向主控服务器推送,流量使用情况的间隔时间
|
||||
GitHash string `desc:"git hash" def:""` //optional git hash
|
||||
BuildTime string `desc:"build time" def:""` //optional build time
|
||||
RunAt string `desc:"run at" def:""` //optional run at
|
||||
IsUserTrafficStat string `desc:"is user traffic stat" def:"false"` //是否开启用户流量统计
|
||||
}
|
||||
|
||||
func (c Config) DisableUserTraffic() bool {
|
||||
if c.IsUserTrafficStat == "" {
|
||||
return false
|
||||
}
|
||||
if strings.ToLower(c.IsUserTrafficStat) == "true" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c Config) SubHostWithPort() []string {
|
||||
|
||||
@@ -106,6 +106,10 @@ func (app *App) loopPush() {
|
||||
}
|
||||
|
||||
func (app *App) trafficInc(uid string, byteN int64) {
|
||||
if app.cfg.DisableUserTraffic() {
|
||||
return
|
||||
}
|
||||
|
||||
kb := byteN >> 10
|
||||
value, ok := app.userUsedTrafficKb.Load(uid)
|
||||
if ok {
|
||||
|
||||
Reference in New Issue
Block a user