fix static check warnings

ws
dingjun 2 years ago
parent 267134144f
commit b0a539ca99

@ -38,8 +38,6 @@ type Client struct {
// addr is server address
//
// conf is the client configure
//
//
func NewClient(c net.Conn, config *ssh.ClientConfig, addr string, conf *Conf) (*Client, error) {
//obfsConn := &TimedOutConn{c, conf.Timeout}
sshConn, newch, reqs, err := ssh.NewClientConn(c, addr, config)
@ -73,9 +71,8 @@ func (cc *Client) Run() error {
go cc.registerSignal()
select {
case <-time.After(1 * time.Second):
}
time.Sleep(1 * time.Second)
// wait port forward to finish
if cc.listeners != nil {
log.Debugf("wait all channel to be done")
@ -420,6 +417,7 @@ func (cc *Client) registerSignal() {
}
// AddDynamicHTTPForward add a http dynamic forward through
//
// secure channel
func (cc *Client) AddDynamicHTTPForward(addr string) error {
log.Debugf("add dynamic http listen: %s", addr)

@ -1,3 +1,4 @@
//go:build windows
// +build windows
package obfssh

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux || openbsd || solaris
// +build darwin freebsd linux openbsd solaris
package obfssh

@ -233,13 +233,11 @@ func main() {
timeout := time.Duration(cfg.KeepaliveInterval*2) * time.Second
var _conn = c
conn := &obfssh.TimedOutConn{Conn: c, Timeout: timeout}
var _conn net.Conn = &obfssh.TimedOutConn{Conn: c, Timeout: timeout}
if cfg.TLS {
log.Debugf("begin tls handshake")
_conn = tls.Client(conn, &tls.Config{
_conn = tls.Client(_conn, &tls.Config{
ServerName: host,
InsecureSkipVerify: cfg.TLSInsecure,
})
@ -310,7 +308,7 @@ func main() {
}
for _, p := range cfg.DynamicForwards {
if strings.Index(p, ":") == -1 {
if !strings.Contains(p, ":") {
local = fmt.Sprintf(":%s", p)
} else {
local = p
@ -322,7 +320,7 @@ func main() {
}
for _, p := range cfg.DynamicHTTP {
if strings.Index(p, ":") == -1 {
if !strings.Contains(p, ":") {
local = fmt.Sprintf(":%s", p)
} else {
local = p
@ -363,10 +361,7 @@ func main() {
func parseForwardAddr(s string) []string {
ss := strings.FieldsFunc(s, func(c rune) bool {
if c == ':' {
return true
}
return false
return c == ':'
})
return ss
}

@ -74,7 +74,7 @@ func main() {
if u, err := conf.getUser(c.User()); err == nil {
for _, pk := range u.publicKeys {
if k.Type() == pk.Type() &&
bytes.Compare(k.Marshal(), pk.Marshal()) == 0 {
bytes.Equal(k.Marshal(), pk.Marshal()) {
return true
}
}

@ -1,3 +1,4 @@
//go:build !linux
// +build !linux
package obfssh

@ -1,3 +1,4 @@
//go:build linux && !cgo
// +build linux,!cgo
package obfssh

@ -1,3 +1,4 @@
//go:build linux && cgo
// +build linux,cgo
package obfssh

@ -34,8 +34,6 @@ type Server struct {
// config is &ssh.ServerConfig
//
// conf is the server configure
//
//
func NewServer(c net.Conn, config *ssh.ServerConfig, conf *Conf) (*Server, error) {
sshConn, ch, req, err := ssh.NewServerConn(&TimedOutConn{c, 15 * 60 * time.Second}, config)
if err != nil {
@ -211,10 +209,10 @@ func (s *session) handleSubsystem(payload []byte) bool {
func (s *session) handleShell() bool {
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
s.env = append(s.env, fmt.Sprintf("SHELL=powershell"))
s.env = append(s.env, "SHELL=powershell")
cmd = exec.Command("powershell")
} else {
s.env = append(s.env, fmt.Sprintf("SHELL=/bin/bash"))
s.env = append(s.env, "SHELL=/bin/bash")
cmd = exec.Command("/bin/bash", "-l")
}
s.cmd = cmd
@ -232,10 +230,10 @@ func (s *session) handleExec(payload []byte) bool {
}
log.Infoln("execute command", _cmd.Arg)
if runtime.GOOS == "windows" {
s.env = append(s.env, fmt.Sprintf("SHELL=powershell"))
s.env = append(s.env, "SHELL=powershell")
cmd = exec.Command("powershell", "-Command", _cmd.Arg)
} else {
s.env = append(s.env, fmt.Sprintf("SHELL=/bin/bash"))
s.env = append(s.env, "SHELL=/bin/bash")
cmd = exec.Command("/bin/bash", "-c", _cmd.Arg)
}
s.cmd = cmd
@ -273,7 +271,7 @@ func (s *session) handlePtyReq(payload []byte) bool {
s.env = append(s.env, fmt.Sprintf("SSH_TTY=%s", s.ptsname))
s.env = append(s.env, fmt.Sprintf("TERM=%s", _ptyReq.Term))
ws, err := s._console.Size()
ws, _ := s._console.Size()
log.Debugf("current console %+v", ws)
ws.Height = uint16(_ptyReq.Rows)
ws.Width = uint16(_ptyReq.Columns)
@ -566,7 +564,7 @@ func (sc *Server) handleTcpipForward(req *ssh.Request) {
return
}
if addr.Port > 65535 || addr.Port < 0 {
if addr.Port > 65535 {
log.Errorf("invalid port %d", addr.Port)
if req.WantReply {
req.Reply(false, nil)

Loading…
Cancel
Save