Skip to content

Commit

Permalink
add: github action
Browse files Browse the repository at this point in the history
  • Loading branch information
huhu415 committed Oct 5, 2024
1 parent 9bc6d7e commit ffd2e66
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 34 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Go Binary for Linux (Multi-arch)

on:
push:
tags:
- "v*"

env:
TZ: Asia/Shanghai

permissions:
contents: write
discussions: write

jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ $RECYCLE.BIN/
.idea
docker-compose.yml
uaProxy
dist/
75 changes: 75 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Make sure to check the documentation at https://goreleaser.com
version: 2

env:
- GIT_URL=https://github.com/huhu415/uaProxy
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- "386"
- amd64
- arm
- arm64
- loong64 # 龙芯
- mips # 32位的大端序MIPS处理器
- mipsle # 32位的小端序MIPS处理器
- mips64 # 64位的大端序MIPS处理器
- mips64le # 64位的小端序MIPS处理器
- ppc64 # 64位的大端序PowerPC处理器
- ppc64le # 64位的小端序PowerPC处理器
- riscv64
flags:
- -trimpath
ldflags:
- -s -w
- -X main.version={{ .Version }}
- -X main.buildDate={{ .Date }}
- -X main.gitCommit={{ .Commit }}

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- README.md
- FAQ.md
- config.yaml
checksum:
name_template: "checksums.txt"

# https://goreleaser.com/customization/changelog/
changelog:
disable: true

# https://goreleaser.com/customization/release
release:
header: |
### 🥳Changes
第一版发布,基本功能完成,已经在寝室开始用3天了。
```sh
tar -xzvf uaProxy-linux-xxxxxxx.tar.gz # 解压
```
footer: |
**FAQ**: https://github.com/huhu415/uaProxy/blob/main/Release.md
47 changes: 47 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## ❓Questions

### 如何选择Assets版本?

- **386**: 32位的x86架构处理器
- **amd64**: 64位的x86架构处理器(也称为x86_64)
- **arm**: 32位的ARM架构处理器
- **arm64**: 64位的ARM架构处理器(也称为AArch64)
- **loong64**: 龙芯处理器的64位架构
- **mips**: 32位的大端序MIPS处理器
- **mipsle**: 32位的小端序MIPS处理器
- **mips64**: 64位的大端序MIPS处理器
- **mips64le**: 64位的小端序MIPS处理器
- **ppc64**: 64位的大端序PowerPC处理器
- **ppc64le**: 64位的小端序PowerPC处理器

> 注意, 所有Assets都是Linux版本的, darwin,windows,freebsd等等请自行编译
### 我是路由器, 选择哪个版本?

先查一下自己的cpu的bits, 是32位还是64位的. _这就可以去掉一半了_

再看看是什么架构, 如果是硬路由, 比如ac2100这种, 一般都是`MIPS`类型的
- 如果是`MIPS`类型的, _那么就看看是大端序还是小端序的, 可以去问[ChatGpt](https://chatgpt.com)或者[kimi](https://kimi.moonshot.cn/chat/)_
- 如果不是, 那就是`ARM`或者`x86`

### 校园网常见检测方式
- [x] TTL
- ```sh
iptables -t mangle -A POSTROUTING -j TTL --ttl-set 64 # 修改出口 TTL 为 64
```
- [x] 时间戳
- ```sh
iptables -t nat -N ntp_force_local
iptables -t nat -I PREROUTING -p udp --dport 123 -j ntp_force_local
iptables -t nat -A ntp_force_local -d 0.0.0.0/8 -j RETURN
iptables -t nat -A ntp_force_local -d 127.0.0.0/8 -j RETURN
iptables -t nat -A ntp_force_local -d 192.168.0.0/16 -j RETURN
iptables -t nat -A ntp_force_local -s 192.168.0.0/16 -j DNAT --to-destination 192.168.1.1 # 根据你路由器的地址修改
# 同时记得修改ntp服务器地址, 可以选ntp.aliyun.com, time1.cloud.tencent.com, time.ustc.edu.cn, cn.pool.ntp.org
```
- [x] UA
- [本项目](https://github.com/huhu415/uaProxy)
- [ ] IP-ID
- 一般学校好像不会检测这个, 以后再说
- [ ] DPI (可能暂时无解)
- 可能要全局代理, 以后再说
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# go build -ldflags "-X main.build=`git rev-parse HEAD`
LDFLAGS := -s -w

VERSION := 1.0.0
VERSION ?= 1.0.0
BUILD_DATE := $(shell date +%Y-%m-%dT%H:%M:%S)
GIT_COMMIT := $(shell git rev-parse --short HEAD) $(shell git log -1 --pretty=%s)

Expand All @@ -17,4 +17,4 @@ build:

# debug: debug
debug:
@CompileDaemon -build="make build" -command="./uaProxy --debug"
@CompileDaemon -build="make build" -command="./uaProxy --debug"
39 changes: 7 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## 使用方法
1. 网关设备开启 IP 转发。
`/etc/sysctl.conf` 文件添加一行 `net.ipv4.ip_forward=1` ,执行下列命令生效:`sysctl -p`

2. 为了实现所有TCP流量会经过uaProxy, iptables要这样设置
```sh
iptables -t nat -N uaProxy # 新建一个名为 uaProxy 的链
Expand All @@ -23,40 +24,14 @@ iptables -t nat -A PREROUTING -p tcp -j uaProxy # 对局域网其他设备进行
iptables -t nat -A OUTPUT -p tcp -j uaProxy # 对本机进行透明代理
```

3. 运行uaProxy(建议uaProxy和config.yaml在一个文件夹下面)
```sh
./uaProxy &
```
> ‼️注意, 因为是利用了iptables的REDIRECT功能, 所以不能和clash, v2ray等软件同时使用, 会有冲突.
> 但这样做也更纯净, 性能最快, 我觉得应该是这个需求的最佳实现方案了.
------------------------------------------

-----------------

## tips

### 校园网多设备检测手段
- [x] TTL
- ```sh
iptables -t mangle -A POSTROUTING -j TTL --ttl-set 64 # 修改出口 TTL 为 64
```
- [x] 时间戳
- ```sh
iptables -t nat -N ntp_force_local
iptables -t nat -I PREROUTING -p udp --dport 123 -j ntp_force_local
iptables -t nat -A ntp_force_local -d 0.0.0.0/8 -j RETURN
iptables -t nat -A ntp_force_local -d 127.0.0.0/8 -j RETURN
iptables -t nat -A ntp_force_local -d 192.168.0.0/16 -j RETURN
iptables -t nat -A ntp_force_local -s 192.168.0.0/16 -j DNAT --to-destination 192.168.1.1 # 根据你路由器的地址修改
# 同时记得修改ntp服务器地址, 可以选ntp.aliyun.com, time1.cloud.tencent.com, time.ustc.edu.cn, cn.pool.ntp.org
```
- [x] UA
- [本项目](https://github.com/huhu415/uaProxy)
- [ ] IP-ID
- 一般学校好像不会检测这个, 以后再说
- [ ] DPI (可能暂时无解)
- 可能要全局代理, 以后再说

### 防 DNS 污染(可有可无)
```sh
# 防 DNS 污染, 全部走本机的dns查询
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53
```
[FAQ](FAQ.md)

0 comments on commit ffd2e66

Please sign in to comment.