Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add codespell #430

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ on: [push, pull_request]
name: CI
jobs:
# ================
# LINTER JOB
# runs on every push and PR
# ================
linter:
name: Linter checks
steps:
- name: Spelling check
uses: codespell-project/actions-codespell@v2
with:
check_filenames: true
check_hidden: true
# ================
# TEST JOB
# runs on every push and PR
# runs 2x3 times (see matrix)
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Config struct {
TLS TLSConfig
}

// Server respresent a chisel service
// Server represent a chisel service
type Server struct {
*cio.Logger
config *Config
Expand Down
6 changes: 3 additions & 3 deletions server/server_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (s *Server) handleClientHandler(w http.ResponseWriter, r *http.Request) {
//websockets upgrade AND has chisel prefix
upgrade := strings.ToLower(r.Header.Get("Upgrade"))
protocol := r.Header.Get("Sec-WebSocket-Protocol")
if upgrade == "websocket" {
if upgrade == "websocket" {
if protocol == chshare.ProtocolVersion {
s.handleWebsocket(w, r)
return
Expand Down Expand Up @@ -123,7 +123,7 @@ func (s *Server) handleWebsocket(w http.ResponseWriter, req *http.Request) {
//confirm reverse tunnels are allowed
if r.Reverse && !s.config.Reverse {
l.Debugf("Denied reverse port forwarding request, please enable --reverse")
failed(s.Errorf("Reverse port forwaring not enabled on server"))
failed(s.Errorf("Reverse port forwarding not enabled on server"))
return
}
//confirm reverse tunnel is available
Expand All @@ -132,7 +132,7 @@ func (s *Server) handleWebsocket(w http.ResponseWriter, req *http.Request) {
return
}
}
//successfuly validated config!
//successfully validated config!
r.Reply(true, nil)
//tunnel per ssh connection
tunnel := tunnel.New(tunnel.Config{
Expand Down
6 changes: 3 additions & 3 deletions share/cnet/conn_ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ type wsConn struct {
buff []byte
}

//NewWebSocketConn converts a websocket.Conn into a net.Conn
// NewWebSocketConn converts a websocket.Conn into a net.Conn
func NewWebSocketConn(websocketConn *websocket.Conn) net.Conn {
c := wsConn{
Conn: websocketConn,
}
return &c
}

//Read is not threadsafe though thats okay since there
//should never be more than one reader
// Read is not threadsafe though that's okay since there
// should never be more than one reader
func (c *wsConn) Read(dst []byte) (int, error) {
ldst := len(dst)
//use buffer or read new message
Expand Down
13 changes: 7 additions & 6 deletions share/cos/signal.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !windows
//go:build !windows
// +build !windows

package cos

Expand All @@ -13,8 +14,8 @@ import (
"github.com/jpillora/sizestr"
)

//GoStats prints statistics to
//stdout on SIGUSR2 (posix-only)
// GoStats prints statistics to
// stdout on SIGUSR2 (posix-only)
func GoStats() {
//silence complaints from windows
const SIGUSR2 = syscall.Signal(0x1f)
Expand All @@ -24,14 +25,14 @@ func GoStats() {
for range c {
memStats := runtime.MemStats{}
runtime.ReadMemStats(&memStats)
log.Printf("recieved SIGUSR2, go-routines: %d, go-memory-usage: %s",
log.Printf("received SIGUSR2, go-routines: %d, go-memory-usage: %s",
runtime.NumGoroutine(),
sizestr.ToString(int64(memStats.Alloc)))
}
}

//AfterSignal returns a channel which will be closed
//after the given duration or until a SIGHUP is received
// AfterSignal returns a channel which will be closed
// after the given duration or until a SIGHUP is received
func AfterSignal(d time.Duration) <-chan struct{} {
ch := make(chan struct{})
go func() {
Expand Down
27 changes: 14 additions & 13 deletions share/tunnel/tunnel_in_proxy_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ import (
"golang.org/x/sync/errgroup"
)

//listenUDP is a special listener which forwards packets via
//the bound ssh connection. tricky part is multiplexing lots of
//udp clients through the entry node. each will listen on its
//own source-port for a response:
// (random)
// src-1 1111->... dst-1 6345->7777
// src-2 2222->... <---> udp <---> udp <-> dst-1 7543->7777
// src-3 3333->... listener handler dst-1 1444->7777
// listenUDP is a special listener which forwards packets via
// the bound ssh connection. tricky part is multiplexing lots of
// udp clients through the entry node. each will listen on its
// own source-port for a response:
//
//we must store these mappings (1111-6345, etc) in memory for a length
//of time, so that when the exit node receives a response on 6345, it
//knows to return it to 1111.
// (random)
// src-1 1111->... dst-1 6345->7777
// src-2 2222->... <---> udp <---> udp <-> dst-1 7543->7777
// src-3 3333->... listener handler dst-1 1444->7777
//
// we must store these mappings (1111-6345, etc) in memory for a length
// of time, so that when the exit node receives a response on 6345, it
// knows to return it to 1111.
func listenUDP(l *cio.Logger, sshTun sshTunnel, remote *settings.Remote) (*udpListener, error) {
a, err := net.ResolveUDPAddr("udp", remote.Local())
if err != nil {
Expand Down Expand Up @@ -64,7 +65,7 @@ type udpListener struct {

func (u *udpListener) run(ctx context.Context) error {
defer u.inbound.Close()
//udp doesnt accept connections,
//udp doesn't accept connections,
//udp simply forwards packets
//and therefore only needs to listen
eg, ctx := errgroup.WithContext(ctx)
Expand Down Expand Up @@ -178,7 +179,7 @@ func (u *udpListener) getUDPChan(ctx context.Context) (*udpChannel, error) {
c: rwc,
}
u.outbound = o
u.Debugf("aquired channel")
u.Debugf("acquired channel")
return o, nil
}

Expand Down