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: use errors.New to replace fmt.Errorf with no parameters #514

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func NewClient(c *Config) (*Client, error) {
}
tc.Certificates = []tls.Certificate{c}
} else if c.TLS.Cert != "" || c.TLS.Key != "" {
return nil, fmt.Errorf("Please specify client BOTH cert and key")
return nil, errors.New("Please specify client BOTH cert and key")
}
client.tlsConfig = tc
}
Expand Down
4 changes: 2 additions & 2 deletions share/settings/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package settings

import (
"encoding/json"
"fmt"
"errors"
)

type Config struct {
Expand All @@ -14,7 +14,7 @@ func DecodeConfig(b []byte) (*Config, error) {
c := &Config{}
err := json.Unmarshal(b, c)
if err != nil {
return nil, fmt.Errorf("Invalid JSON config")
return nil, errors.New("Invalid JSON config")
}
return c, nil
}
Expand Down
26 changes: 14 additions & 12 deletions share/tunnel/tunnel_in_proxy_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tunnel
import (
"context"
"encoding/gob"
"errors"
"fmt"
"io"
"net"
Expand All @@ -18,18 +19,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 @@ -159,7 +161,7 @@ func (u *udpListener) getUDPChan(ctx context.Context) (*udpChannel, error) {
//not cached, bind
sshConn := u.sshTun.getSSH(ctx)
if sshConn == nil {
return nil, fmt.Errorf("ssh-conn nil")
return nil, errors.New("ssh-conn nil")
}
//ssh request for udp packets for this proxy's remote,
//just "udp" since the remote address is sent with each packet
Expand Down