Skip to content

Commit ba8540b

Browse files
authored
Merge pull request #81 from lwch/dev
v0.13.0
2 parents 1d5e90a + e47456c commit ba8540b

File tree

21 files changed

+114
-79
lines changed

21 files changed

+114
-79
lines changed

.github/workflows/build-builder-image.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@ on:
77
- cron: '30 0 * * *'
88

99
env:
10-
GO_VERSION: "1.20.3"
10+
GO_VERSION: "1.20.11"
1111

1212
jobs:
1313

1414
build:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
with:
1919
ref: builder
2020

21-
- uses: docker/setup-qemu-action@v2
22-
- uses: docker/setup-buildx-action@v2
21+
- uses: docker/setup-qemu-action@v3
22+
- uses: docker/setup-buildx-action@v3
2323

24-
- uses: docker/login-action@v2
24+
- uses: docker/login-action@v3
2525
with:
2626
username: ${{ secrets.DOCKERHUB_USERNAME }}
2727
password: ${{ secrets.DOCKERHUB_TOKEN }}
2828

29-
- uses: docker/build-push-action@v3
29+
- uses: docker/build-push-action@v5
3030
with:
3131
context: .
32+
pull: true
3233
push: true
3334
tags: lwch/natpass-builder:${{ env.GO_VERSION }}
3435
build-args: |

.github/workflows/build-release-image.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
with:
1616
ref: release
1717

18-
- uses: docker/setup-qemu-action@v2
19-
- uses: docker/setup-buildx-action@v2
18+
- uses: docker/setup-qemu-action@v3
19+
- uses: docker/setup-buildx-action@v3
2020

21-
- uses: docker/login-action@v2
21+
- uses: docker/login-action@v3
2222
with:
2323
username: ${{ secrets.DOCKERHUB_USERNAME }}
2424
password: ${{ secrets.DOCKERHUB_TOKEN }}
2525

26-
- uses: docker/build-push-action@v3
26+
- uses: docker/build-push-action@v5
2727
with:
2828
context: .
29+
pull: true
2930
push: true
3031
tags: lwch/natpass-release

.github/workflows/build.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ jobs:
1515
os:
1616
- ubuntu-20.04
1717
- ubuntu-22.04
18-
- windows-2019
19-
- windows-2022
20-
- macos-10.15
2118
- macos-11
2219
- macos-12
20+
- macos-13
2321
go:
2422
- '1.18'
2523
- '1.19'
2624
- '1.20'
2725
steps:
28-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2927

3028
- name: Set up Go
31-
uses: actions/setup-go@v3
29+
uses: actions/setup-go@v4
3230
with:
3331
go-version: ${{ matrix.go }}
3432

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- id: get_version
1313
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
1414

15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616

1717
- name: build
1818
uses: lwch/natpass@builder

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,10 @@
220220
## v0.12.3
221221

222222
1. go版本升级到1.20.3
223-
2. 更新第三方库
223+
2. 更新第三方库
224+
225+
## v0.13.0
226+
227+
1. 支持自动生成local_port
228+
2. 更新第三方库
229+
3. go版本升级到1.20.11

code/client/app/handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (p *program) shellCreate(mgr *rule.Mgr, conn *conn.Conn, msg *network.Msg)
3030
create := msg.GetCreq()
3131
tn := mgr.GetLinked(create.GetName(), msg.GetFrom())
3232
if tn == nil {
33-
tn = shell.New(global.Rule{
33+
tn = shell.New(&global.Rule{
3434
Name: create.GetName(),
3535
Target: msg.GetFrom(),
3636
Type: "shell",
@@ -57,7 +57,7 @@ func (p *program) vncCreate(confDir string, mgr *rule.Mgr, conn *conn.Conn, msg
5757
create := msg.GetCreq()
5858
tn := mgr.GetLinked(create.GetName(), msg.GetFrom())
5959
if tn == nil {
60-
tn = vnc.New(global.Rule{
60+
tn = vnc.New(&global.Rule{
6161
Name: create.GetName(),
6262
Target: msg.GetFrom(),
6363
Type: "vnc",
@@ -92,7 +92,7 @@ func (p *program) codeCreate(confDir string, mgr *rule.Mgr, conn *conn.Conn, msg
9292
create := msg.GetCreq()
9393
tn := mgr.GetLinked(create.GetName(), msg.GetFrom())
9494
if tn == nil {
95-
tn = code.New(global.Rule{
95+
tn = code.New(&global.Rule{
9696
Name: create.GetName(),
9797
Target: msg.GetFrom(),
9898
Type: "code-server",

code/client/conn/send_conn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
// SendConnectReq send connect request message
12-
func (conn *Conn) SendConnectReq(id string, cfg global.Rule) {
12+
func (conn *Conn) SendConnectReq(id string, cfg *global.Rule) {
1313
var msg network.Msg
1414
msg.To = cfg.Target
1515
msg.XType = network.Msg_connect_req
@@ -68,7 +68,7 @@ func (conn *Conn) SendConnectReq(id string, cfg global.Rule) {
6868
}
6969

7070
// SendConnectVnc send connect vnc request message
71-
func (conn *Conn) SendConnectVnc(id string, cfg global.Rule, quality uint64, showCursor bool) {
71+
func (conn *Conn) SendConnectVnc(id string, cfg *global.Rule, quality uint64, showCursor bool) {
7272
var msg network.Msg
7373
msg.To = cfg.Target
7474
msg.XType = network.Msg_connect_req

code/client/global/conf.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Configure struct {
4242
DashboardEnabled bool
4343
DashboardListen string
4444
DashboardPort uint16
45-
Rules []Rule
45+
Rules []*Rule
4646
CodeDir string
4747
}
4848

@@ -70,8 +70,8 @@ func LoadConf(dir string) *Configure {
7070
Listen string `yaml:"listen"`
7171
Port uint16 `yaml:"port"`
7272
} `yaml:"dashboard"`
73-
Rules []Rule `yaml:"rules"`
74-
CodeDir string `yaml:"codedir"`
73+
Rules []*Rule `yaml:"rules"`
74+
CodeDir string `yaml:"codedir"`
7575
}
7676
cfg.ID = "unset"
7777
cfg.Server = "127.0.0.1:6154"

code/client/global/port.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package global
2+
3+
import (
4+
"net"
5+
6+
"github.com/lwch/runtime"
7+
)
8+
9+
// GeneratePort generate port for listen
10+
func GeneratePort() uint16 {
11+
l, err := net.ListenTCP("tcp", &net.TCPAddr{})
12+
runtime.Assert(err)
13+
defer l.Close()
14+
return uint16(l.Addr().(*net.TCPAddr).Port)
15+
}

0 commit comments

Comments
 (0)