Commit 251f9130 authored by ibuler's avatar ibuler

[Update] 切换到ibuler/ssh

No related merge requests found
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
revision = "648efa622239a2f6ff949fed78ee37b48d499ba4" revision = "648efa622239a2f6ff949fed78ee37b48d499ba4"
[[projects]] [[projects]]
digest = "1:c3f0e909d9834aede2dca8824d35f8def272defc400e530bd0e76481a43e1f38" digest = "1:74d60c90a8daf329b92887e404a23d999ff95bc7a9c111476c1753bcf178e384"
name = "github.com/gliderlabs/ssh" name = "github.com/ibuler/ssh"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "4b72c663cfb315ecfb9f6be5c106c0c693ce196b" revision = "d3a6756290240931faaf90ec97ddd5d9290623d8"
version = "v0.1.3" version = "v0.1.1"
[[projects]] [[projects]]
digest = "1:e77a03f1e4f1e4e035e46dc3cd79b1e33acbf651540aaa5e148caf1296884d18" digest = "1:e77a03f1e4f1e4e035e46dc3cd79b1e33acbf651540aaa5e148caf1296884d18"
...@@ -33,6 +33,14 @@ ...@@ -33,6 +33,14 @@
revision = "f55edac94c9bbba5d6182a4be46d86a2c9b5b50e" revision = "f55edac94c9bbba5d6182a4be46d86a2c9b5b50e"
version = "v1.0.2" version = "v1.0.2"
[[projects]]
digest = "1:9cedee824c21326bd26950bd9e1ffe9dc4e7ca03dc8634d0e6f954ee6a383172"
name = "github.com/kr/fs"
packages = ["."]
pruneopts = "UT"
revision = "1455def202f6e05b95cc7bfc7e8ae67ae5141eba"
version = "v0.1.0"
[[projects]] [[projects]]
digest = "1:47dc4f6ee8a7dda99b516b56cb7fcc4f53ca94756263bdcea55c918a60126062" digest = "1:47dc4f6ee8a7dda99b516b56cb7fcc4f53ca94756263bdcea55c918a60126062"
name = "github.com/kr/pty" name = "github.com/kr/pty"
...@@ -57,6 +65,22 @@ ...@@ -57,6 +65,22 @@
revision = "e6d60cf7ba1f42d86d54cdf5508611c4aafb3970" revision = "e6d60cf7ba1f42d86d54cdf5508611c4aafb3970"
version = "v0.0.1" version = "v0.0.1"
[[projects]]
digest = "1:cf31692c14422fa27c83a05292eb5cbe0fb2775972e8f1f8446a71549bd8980b"
name = "github.com/pkg/errors"
packages = ["."]
pruneopts = "UT"
revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4"
version = "v0.8.1"
[[projects]]
digest = "1:6c187bc42f50a341b0dd25da7f5bcf84b4bbffa7193b92f3c983c1a9803a447a"
name = "github.com/pkg/sftp"
packages = ["."]
pruneopts = "UT"
revision = "a713b07e6d90e1831d7fefcb69f1310edb3783ae"
version = "v1.10.0"
[[projects]] [[projects]]
digest = "1:274f67cb6fed9588ea2521ecdac05a6d62a8c51c074c1fccc6a49a40ba80e925" digest = "1:274f67cb6fed9588ea2521ecdac05a6d62a8c51c074c1fccc6a49a40ba80e925"
name = "github.com/satori/go.uuid" name = "github.com/satori/go.uuid"
...@@ -83,7 +107,7 @@ ...@@ -83,7 +107,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:7d2f4682bbf020a09e42b95e3ab8ff8eaf1301ccd3184c98fb8baffd3cf02427" digest = "1:7ba755bbcaaf821fd0c73c96069883c4467d6e261e3ecc81adddb8e0bfc67527"
name = "golang.org/x/crypto" name = "golang.org/x/crypto"
packages = [ packages = [
"curve25519", "curve25519",
...@@ -96,11 +120,11 @@ ...@@ -96,11 +120,11 @@
"ssh/terminal", "ssh/terminal",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "88737f569e3a9c7ab309cdc09a07fe7fc87233c3" revision = "c05e17bb3b2dca130fc919668a96b4bec9eb9442"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:dd68f2bed31a27f4e2aff98c48d185b9e19d29d0b81fb0f81f58ec50469c2e4b" digest = "1:91f01f15f85f43f18cbed401dfc839879a12678f8254fcfe93daaddd4a3e52e0"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = [ packages = [
"cpu", "cpu",
...@@ -108,7 +132,7 @@ ...@@ -108,7 +132,7 @@
"windows", "windows",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "16da32be82c5df9a338c27758247c0b7b0bd8fea" revision = "16072639606ea9e22c7d86e4cbd6af6314f4193c"
[[projects]] [[projects]]
digest = "1:4d2e5a73dc1500038e504a8d78b986630e3626dc027bc030ba5c75da257cdb96" digest = "1:4d2e5a73dc1500038e504a8d78b986630e3626dc027bc030ba5c75da257cdb96"
...@@ -122,10 +146,11 @@ ...@@ -122,10 +146,11 @@
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
input-imports = [ input-imports = [
"github.com/gliderlabs/ssh", "github.com/ibuler/ssh",
"github.com/jarcoal/httpmock", "github.com/jarcoal/httpmock",
"github.com/kr/pty", "github.com/kr/pty",
"github.com/olekukonko/tablewriter", "github.com/olekukonko/tablewriter",
"github.com/pkg/sftp",
"github.com/satori/go.uuid", "github.com/satori/go.uuid",
"github.com/sirupsen/logrus", "github.com/sirupsen/logrus",
"github.com/xlab/treeprint", "github.com/xlab/treeprint",
......
...@@ -26,8 +26,16 @@ ...@@ -26,8 +26,16 @@
[[constraint]] [[constraint]]
name = "github.com/gliderlabs/ssh" name = "github.com/ibuler/ssh"
version = "0.1.3" version = "0.1.1"
[[constraint]]
name = "github.com/jarcoal/httpmock"
version = "1.0.3"
[[constraint]]
name = "github.com/kr/pty"
version = "1.1.4"
[[constraint]] [[constraint]]
name = "github.com/olekukonko/tablewriter" name = "github.com/olekukonko/tablewriter"
...@@ -56,3 +64,7 @@ ...@@ -56,3 +64,7 @@
[prune] [prune]
go-tests = true go-tests = true
unused-packages = true unused-packages = true
[[constraint]]
name = "github.com/pkg/sftp"
version = "1.10.0"
module cocogo
go 1.12
require (
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
github.com/gliderlabs/ssh v0.1.3
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/olekukonko/tablewriter v0.0.1
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.4.0
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576
gopkg.in/yaml.v2 v2.2.2
)
...@@ -3,7 +3,7 @@ package auth ...@@ -3,7 +3,7 @@ package auth
import ( import (
"strings" "strings"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
gossh "golang.org/x/crypto/ssh" gossh "golang.org/x/crypto/ssh"
"cocogo/pkg/cctx" "cocogo/pkg/cctx"
...@@ -23,9 +23,9 @@ func checkAuth(ctx ssh.Context, password, publicKey string) (ok bool) { ...@@ -23,9 +23,9 @@ func checkAuth(ctx ssh.Context, password, publicKey string) (ok bool) {
} }
if user == nil { if user == nil {
action = "Failed" action = "Failed"
ok = false
} else { } else {
ctx.SetValue(cctx.ContextKeyUser, user) ctx.SetValue(cctx.ContextKeyUser, user)
ok = true
} }
logger.Infof("%s %s for %s from %s", action, authMethod, username, remoteAddr) logger.Infof("%s %s for %s from %s", action, authMethod, username, remoteAddr)
return ok return ok
......
...@@ -2,7 +2,7 @@ package cctx ...@@ -2,7 +2,7 @@ package cctx
import ( import (
"context" "context"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
"cocogo/pkg/sdk" "cocogo/pkg/sdk"
) )
......
...@@ -3,7 +3,7 @@ package proxy ...@@ -3,7 +3,7 @@ package proxy
import ( import (
"cocogo/pkg/logger" "cocogo/pkg/logger"
"cocogo/pkg/service" "cocogo/pkg/service"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
"cocogo/pkg/sdk" "cocogo/pkg/sdk"
) )
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"io" "io"
"time" "time"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
gossh "golang.org/x/crypto/ssh" gossh "golang.org/x/crypto/ssh"
"cocogo/pkg/logger" "cocogo/pkg/logger"
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
gossh "golang.org/x/crypto/ssh" gossh "golang.org/x/crypto/ssh"
) )
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"context" "context"
"sync" "sync"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
"cocogo/pkg/logger" "cocogo/pkg/logger"
"cocogo/pkg/sdk" "cocogo/pkg/sdk"
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"io" "io"
"text/template" "text/template"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
"cocogo/pkg/logger" "cocogo/pkg/logger"
) )
......
package handler package handler
import ( import (
"cocogo/pkg/proxybak" //"cocogo/pkg/proxybak"
//"cocogo/pkg/proxybak"
"context" "context"
//"context" //"context"
//"strconv" //"strconv"
...@@ -16,7 +17,7 @@ import ( ...@@ -16,7 +17,7 @@ import (
"sync" "sync"
//"time" //"time"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
//"github.com/olekukonko/tablewriter" //"github.com/olekukonko/tablewriter"
//"github.com/satori/go.uuid" //"github.com/satori/go.uuid"
//"github.com/xlab/treeprint" //"github.com/xlab/treeprint"
...@@ -29,7 +30,6 @@ import ( ...@@ -29,7 +30,6 @@ import (
"cocogo/pkg/model" "cocogo/pkg/model"
"cocogo/pkg/sdk" "cocogo/pkg/sdk"
"cocogo/pkg/service" "cocogo/pkg/service"
"cocogo/pkg/userhome"
//"cocogo/pkg/proxy" //"cocogo/pkg/proxy"
//"cocogo/pkg/transport" //"cocogo/pkg/transport"
//"cocogo/pkg/userhome" //"cocogo/pkg/userhome"
...@@ -265,26 +265,26 @@ func (i *InteractiveHandler) changeLanguage() { ...@@ -265,26 +265,26 @@ func (i *InteractiveHandler) changeLanguage() {
} }
func (i *InteractiveHandler) JoinShareRoom(roomID string) { func (i *InteractiveHandler) JoinShareRoom(roomID string) {
sshConn := userhome.NewSSHConn(i.sess) //sshConn := userhome.NewSSHConn(i.sess)
ctx, cancelFuc := context.WithCancel(i.sess.Context()) //ctx, cancelFuc := context.WithCancel(i.sess.Context())
//
_, winCh, _ := i.sess.Pty() //_, winCh, _ := i.sess.Pty()
go func() { //go func() {
for { // for {
select { // select {
case <-ctx.Done(): // case <-ctx.Done():
return // return
case win, ok := <-winCh: // case win, ok := <-winCh:
if !ok { // if !ok {
return // return
} // }
fmt.Println("join term change:", win) // fmt.Println("join term change:", win)
} // }
} // }
}() //}()
proxybak.Manager.JoinShareRoom(roomID, sshConn) //proxybak.Manager.JoinShareRoom(roomID, sshConn)
logger.Info("exit room id:", roomID) logger.Info("exit room id:", roomID)
cancelFuc() //cancelFuc()
} }
......
package handler
import (
"io"
"io/ioutil"
"github.com/ibuler/ssh"
"github.com/pkg/sftp"
"cocogo/pkg/logger"
)
func SftpHandler(sess ssh.Session) {
debugStream := ioutil.Discard
serverOptions := []sftp.ServerOption{
sftp.WithDebug(debugStream),
}
server, err := sftp.NewServer(
sess,
serverOptions...,
)
if err != nil {
logger.Errorf("sftp server init error: %s", err)
return
}
if err := server.Serve(); err == io.EOF {
server.Close()
logger.Info("sftp client exited session.")
} else if err != nil {
logger.Errorf("sftp server completed with error:", err)
}
}
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"syscall" "syscall"
"unsafe" "unsafe"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
"github.com/kr/pty" "github.com/kr/pty"
) )
......
...@@ -3,7 +3,7 @@ package sshd ...@@ -3,7 +3,7 @@ package sshd
import ( import (
"strconv" "strconv"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
"cocogo/pkg/auth" "cocogo/pkg/auth"
"cocogo/pkg/config" "cocogo/pkg/config"
...@@ -34,6 +34,8 @@ func StartServer() { ...@@ -34,6 +34,8 @@ func StartServer() {
HostSigners: []ssh.Signer{signer}, HostSigners: []ssh.Signer{signer},
Version: version, Version: version,
Handler: handler.SessionHandler, Handler: handler.SessionHandler,
SubsystemHandlers: map[string]ssh.SubsystemHandler{},
} }
srv.SetSubsystemHandler("sftp", handler.SftpHandler)
logger.Fatal(srv.ListenAndServe()) logger.Fatal(srv.ListenAndServe())
} }
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"
) )
......
...@@ -3,7 +3,7 @@ package userhome ...@@ -3,7 +3,7 @@ package userhome
import ( import (
"context" "context"
"github.com/gliderlabs/ssh" "github.com/ibuler/ssh"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment