Skip to content

Commit

Permalink
fix: use release binary instead of self compiling (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
DVKunion authored Jan 18, 2024
1 parent 122435f commit 7cb82c8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
*.tar.gz

# Test binary, built with `go test -c`
*.test
Expand Down
4 changes: 2 additions & 2 deletions cmd/client/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func listen(ctx context.Context, server net.Listener, pa string, pt tunnel.Type,
if err != nil {
slog.Error(consts.ACCEPT_ERROR, "err", err)
}
if srv, ok := service.Factory[pt]; ok {
destConn, err := srv.Conn(ctx, t, service.WithAddr(pa))
if srv, ok := service.Factory.Load(pt); ok {
destConn, err := srv.(service.Service).Conn(ctx, t, service.WithAddr(pa))
if err != nil {
slog.Error(consts.CONNECT_RMOET_ERROR, "err", err)
continue
Expand Down
4 changes: 2 additions & 2 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func New(opts ...Option) (*Server, error) {
}
}
// check
if srv, ok := service.Factory[s.opts.proto]; ok {
s.srv = srv
if srv, ok := service.Factory.Load(s.opts.proto); ok {
s.srv = srv.(service.Service)
}

if s.srv == nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"context"
"net"
"sync"

"github.com/DVKunion/SeaMoon/pkg/transfer"
"github.com/DVKunion/SeaMoon/pkg/tunnel"
Expand All @@ -13,8 +14,8 @@ type Service interface {
Serve(ln net.Listener, srvOpt ...Option) error
}

var Factory = map[tunnel.Type]Service{}
var Factory = sync.Map{}

func register(t tunnel.Type, s Service) {
Factory[t] = s
Factory.Store(t, s)
}
4 changes: 2 additions & 2 deletions s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ vars:

actions:
pre-deploy:
- run: go mod tidy
- run: wget https://github.com/DVKunion/SeaMoon/releases/download/1.2.0-beta.1/SeaMoon_1.2.0-beta.1_linux_amd64.tar.gz
path: ./
- run: GO111MODULE=on GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/DVKunion/SeaMoon/pkg/consts.Version=2.0.0-beta.1" -o seamoon cmd/main.go
- run: tar -zvxf SeaMoon_1.2.0-beta.1_linux_amd64.tar.gz
path: ./
- run: chmod +x seamoon
path: ./
Expand Down

0 comments on commit 7cb82c8

Please # to comment.