Skip to content

Commit

Permalink
chore(go): fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness4 committed Dec 1, 2023
1 parent 41a86a0 commit 73550ff
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: ghcr.io/darkness4/dpsproxy-server:latest
tags: ghcr.io/deepsquare-io/dpsproxy-server:latest
build-args: |
VERSION=dev
cache-from: type=gha
Expand Down Expand Up @@ -118,9 +118,9 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/darkness4/dpsproxy-server:latest
ghcr.io/darkness4/dpsproxy-server:dev
ghcr.io/darkness4/dpsproxy-server:${{ steps.get_version.outputs.VERSION }}
ghcr.io/deepsquare-io/dpsproxy-server:latest
ghcr.io/deepsquare-io/dpsproxy-server:dev
ghcr.io/deepsquare-io/dpsproxy-server:${{ steps.get_version.outputs.VERSION }}
build-args: |
${{ steps.get_version.outputs.VERSION }}
cache-from: type=gha
Expand Down
4 changes: 1 addition & 3 deletions cmd/dpsproxy-server/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Auth Web3 HTMX is a simple demonstration of Web3 in combination with HTMX, written in Go.
*/package main
package main

import (
"context"
Expand Down
3 changes: 1 addition & 2 deletions cmd/dpsproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ var app = &cli.App{
if reconnect {
if errors.Is(err, io.EOF) {
return nil
} else {
log.Err(err).Msg("client failure")
}
log.Err(err).Msg("client failure")
select {
case <-time.After(time.Second * 10):
continue
Expand Down
9 changes: 5 additions & 4 deletions ssh/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,10 @@ func (c *client) handleTCPIPForward(
if errors.As(err, &netErr) && netErr.Timeout() {
c.log.Warn().Err(err).Msg("accept failed with timeout")
continue
} else {
c.log.Warn().Err(err).Msg("accept failed")

return err
}
c.log.Warn().Err(err).Msg("accept failed")

return err
}

go func() {
Expand Down Expand Up @@ -382,6 +381,8 @@ func (c *client) pipe(ctx context.Context, ch ssh.Channel, conn net.Conn) error
return ctx.Err()
}

// ForwardHTTP is a middleware that forwards HTTP request based on the subdomain
// to a corresponding SSH client.
func (s *Server) ForwardHTTP(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
host, _, err := net.SplitHostPort(r.Host)
Expand Down
3 changes: 3 additions & 0 deletions utils/generate_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ const maxPort = 60000
const safeMinPort = 60001
const safeMaxPort = 65535

// GenerateRandomPort generates a random port in a range.
func GenerateRandomPort() int64 {
return rand.Int63n(maxPort-minPort+1) + minPort
}

// GenerateSafeRandomPort generates a random port in a safe range.
func GenerateSafeRandomPort() int64 {
return rand.Int63n(safeMaxPort-safeMinPort+1) + safeMinPort
}

const subdomainLength = 10

// GenerateSubdomain generates a random subdomain
func GenerateSubdomain() string {
// Define the character set for the subdomain
charSet := "abcdefghijklmnopqrstuvwxyz0123456789"
Expand Down

0 comments on commit 73550ff

Please sign in to comment.