From 09a602e14b6e14b2d5091f99c78d944b37e166f1 Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 3 Dec 2020 11:23:24 +0800 Subject: [PATCH] opt some --- base/ssh/scripts.go | 8 +++++++- go.mod | 4 ++-- go.sum | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/base/ssh/scripts.go b/base/ssh/scripts.go index 77c95050..51cf3560 100644 --- a/base/ssh/scripts.go +++ b/base/ssh/scripts.go @@ -54,7 +54,13 @@ func Script(m *ice.Message, name string) io.Reader { } m.Option("_script", name) - if s, e := os.Open(path.Join(m.Option(nfs.DIR_ROOT), name)); e == nil { + back := kit.Split(m.Option(nfs.DIR_ROOT)) + for i := len(back) - 1; i >= 0; i-- { + if s, e := os.Open(path.Join(path.Join(back[:i]...), name)); e == nil { + return s + } + } + if s, e := os.Open(name); e == nil { return s } diff --git a/go.mod b/go.mod index 89653029..5fe2e18e 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,9 @@ require ( github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f github.com/gorilla/websocket v1.4.2 github.com/kr/pty v1.1.1 - github.com/mattn/go-colorable v0.1.8 // indirect + github.com/mattn/go-colorable v0.1.8 github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 - github.com/shylinux/toolkits v0.2.0 + github.com/shylinux/toolkits v0.2.1 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 diff --git a/go.sum b/go.sum index 97aa8c67..c6630b1f 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I= github.com/shylinux/toolkits v0.2.0 h1:ZMJGFqqgZBXxu2jUw2Zqu8Vx8KhEgWcMBnlH3cR+MPQ= github.com/shylinux/toolkits v0.2.0/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g= +github.com/shylinux/toolkits v0.2.1 h1:FNCL4Tz6KRHjJbJFGswRLAROzo/AJavW+MrcIOEuB34= +github.com/shylinux/toolkits v0.2.1/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2/go.mod h1:lPnW9HVS0vJdeYyQtOvIvlXgZPNhUAhwz+z5r8AJk0Y=