Skip to content

Commit

Permalink
feat: 统一修改命令名为 traffic-replicator ,增加 goreleaser 配置及 github ci 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
taills committed Jan 10, 2024
1 parent 50c4229 commit 23372d2
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 8 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: 标签推送😂

on:
push:
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
builds:
- id: "traffic-replicator"
main: cmd/traffic-replicator/main.go
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
- 386
env:
- CGO_ENABLED=0

archives:
- id: foo
name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
{{- if eq .Os "linux"}}Linux{{ else if eq .Os "darwin"}}Darwin{{ else }}{{ .Os }}{{ end }}_
{{- if eq .Arch "386" }}i386{{ else if eq .Arch "amd64" }}x86_64{{ else }}{{ .Arch }}{{ end }}
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
8 changes: 4 additions & 4 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TCP is two-way replication. After the port receives data, it will copy the data
#### 1.1 Download and install using go

```shell
go install github.com/taills/traffic-replicator/cmd/ipcopy@latest
go install github.com/taills/traffic-replicator/cmd/traffic-replicator@latest
```

#### 1.2 Use binary files
Expand All @@ -31,17 +31,17 @@ Download the binary file for the corresponding platform from https://github.com/
Copy the UDP traffic of ports 53, 514-550 on this machine to two hosts, 192.168.0.22 and 192.168.0.23, and output the data packets in ASCII format.

```shell
ipcopy -targets 192.168.0.22,192.168.0.23 -ports 53,514-550 -udp -ascii
traffic-replicator -targets 192.168.0.22,192.168.0.23 -ports 53,514-550 -udp -ascii
```

Copy the TCP traffic of port 1024 on this machine to 10.100.0.171.

```shell
ipcopy -targets 10.100.0.171 -ports 1024 -tcp -ascii
traffic-replicator -targets 10.100.0.171 -ports 1024 -tcp -ascii
```

### 3. Help

```shell
ipcopy -h
traffic-replicator -h
```
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TCP为双向复制,端口收到数据后,会将数据复制到所有的目
#### 1.1 使用 go 下载安装

```shell
go install github.com/taills/traffic-replicator/cmd/ipcopy@latest
go install github.com/taills/traffic-replicator/cmd/traffic-replicator@latest
```

#### 1.2 使用二进制文件
Expand All @@ -30,17 +30,17 @@ go install github.com/taills/traffic-replicator/cmd/ipcopy@latest
复制本机53端口,514-550端口的UDP流量到 192.168.0.22 和 192.168.0.23 两台主机上,并以ASCII格式输出数据包。

```shell
ipcopy -targets 192.168.0.22,192.168.0.23 -ports 53,514-550 -udp -ascii
traffic-replicator -targets 192.168.0.22,192.168.0.23 -ports 53,514-550 -udp -ascii
```

复制本机的 1024 端口的TCP流量到 10.100.0.171

```shell
ipcopy -targets 10.100.0.171 -ports 1024 -tcp -ascii
traffic-replicator -targets 10.100.0.171 -ports 1024 -tcp -ascii
```

### 3. 帮助

```shell
ipcopy -h
traffic-replicator -h
```
File renamed without changes.
1 change: 1 addition & 0 deletions dist/artifacts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"traffic-replicator","path":"dist/traffic-replicator_linux_386/traffic-replicator","goos":"linux","goarch":"386","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":"","ID":"traffic-replicator"}},{"name":"traffic-replicator.exe","path":"dist/traffic-replicator_windows_386/traffic-replicator.exe","goos":"windows","goarch":"386","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":".exe","ID":"traffic-replicator"}},{"name":"traffic-replicator","path":"dist/traffic-replicator_linux_amd64_v1/traffic-replicator","goos":"linux","goarch":"amd64","goamd64":"v1","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":"","ID":"traffic-replicator"}},{"name":"traffic-replicator.exe","path":"dist/traffic-replicator_windows_arm64/traffic-replicator.exe","goos":"windows","goarch":"arm64","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":".exe","ID":"traffic-replicator"}},{"name":"traffic-replicator","path":"dist/traffic-replicator_linux_arm64/traffic-replicator","goos":"linux","goarch":"arm64","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":"","ID":"traffic-replicator"}},{"name":"traffic-replicator.exe","path":"dist/traffic-replicator_windows_amd64_v1/traffic-replicator.exe","goos":"windows","goarch":"amd64","goamd64":"v1","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":".exe","ID":"traffic-replicator"}},{"name":"traffic-replicator","path":"dist/traffic-replicator_darwin_amd64_v1/traffic-replicator","goos":"darwin","goarch":"amd64","goamd64":"v1","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":"","ID":"traffic-replicator"}},{"name":"traffic-replicator","path":"dist/traffic-replicator_darwin_arm64/traffic-replicator","goos":"darwin","goarch":"arm64","internal_type":4,"type":"Binary","extra":{"Binary":"traffic-replicator","Ext":"","ID":"traffic-replicator"}}]
119 changes: 119 additions & 0 deletions dist/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
project_name: traffic-replicator
release:
github:
owner: taills
name: traffic-replicator
name_template: '{{.Tag}}'
builds:
- id: traffic-replicator
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
- "386"
goarm:
- "6"
gomips:
- hardfloat
goamd64:
- v1
targets:
- linux_amd64_v1
- linux_arm64
- linux_386
- darwin_amd64_v1
- darwin_arm64
- windows_amd64_v1
- windows_arm64
- windows_386
dir: .
main: cmd/traffic-replicator/main.go
binary: traffic-replicator
builder: go
gobinary: go
command: build
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
env:
- CGO_ENABLED=0
archives:
- id: foo
name_template: '{{ .ProjectName }}_ {{- .Version }}_ {{- if eq .Os "linux"}}Linux{{ else if eq .Os "darwin"}}Darwin{{ else }}{{ .Os }}{{ end }}_ {{- if eq .Arch "386" }}i386{{ else if eq .Arch "amd64" }}x86_64{{ else }}{{ .Arch }}{{ end }}'
format: tar.gz
files:
- src: license*
- src: LICENSE*
- src: readme*
- src: README*
- src: changelog*
- src: CHANGELOG*
snapshot:
name_template: '{{ .Tag }}-next'
checksum:
name_template: checksums.txt
algorithm: sha256
changelog:
filters:
exclude:
- '^docs:'
- '^test:'
sort: asc
dist: dist
env_files:
github_token: ~/.config/goreleaser/github_token
gitlab_token: ~/.config/goreleaser/gitlab_token
gitea_token: ~/.config/goreleaser/gitea_token
source:
name_template: '{{ .ProjectName }}-{{ .Version }}'
format: tar.gz
gomod:
gobinary: go
announce:
twitter:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
mastodon:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
server: ""
reddit:
title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
url_template: '{{ .ReleaseURL }}'
slack:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
username: GoReleaser
discord:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
author: GoReleaser
color: "3888754"
icon_url: https://goreleaser.com/static/avatar.png
teams:
title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
color: '#2D313E'
icon_url: https://goreleaser.com/static/avatar.png
smtp:
subject_template: '{{ .ProjectName }} {{ .Tag }} is out!'
body_template: 'You can view details from: {{ .ReleaseURL }}'
mattermost:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
username: GoReleaser
linkedin:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
telegram:
message_template: '{{ .ProjectName }} {{ mdv2escape .Tag }} is out! Check it out at {{ mdv2escape .ReleaseURL }}'
parse_mode: MarkdownV2
webhook:
message_template: '{ "message": "{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}"}'
content_type: application/json; charset=utf-8
opencollective:
title_template: '{{ .Tag }}'
message_template: '{{ .ProjectName }} {{ .Tag }} is out!<br/>Check it out at <a href="{{ .ReleaseURL }}">{{ .ReleaseURL }}</a>'
git:
tag_sort: -version:refname
github_urls:
download: https://github.com
gitlab_urls:
download: https://gitlab.com
1 change: 1 addition & 0 deletions dist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"project_name":"traffic-replicator","tag":"v0.0.0","previous_tag":"","version":"v0.0.0-next","commit":"50c4229e0d82d2cb2993fc26b2d7996f7cbc35a7","date":"2024-01-10T12:44:33.499928+08:00","runtime":{"goos":"darwin","goarch":"amd64"}}
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.

0 comments on commit 23372d2

Please sign in to comment.