Compare commits

..

7 Commits

Author SHA1 Message Date
Manfred Touron
a125e25b04 Merge pull request #78 from Raerten/dev/moul/support-windows
[FIX] log path and log filename for Windows OS
2018-11-16 09:58:46 +01:00
Дмитрий Шульгачик
07e6344c82 fix log path and log filename for Windows OS 2018-11-16 09:56:33 +01:00
Manfred Touron
d016e674a8 do not use pty on windows for compatiblity (#42) 2018-11-16 09:56:33 +01:00
Manfred Touron
64c8e01c33 Merge pull request #80 from ahhx/idle-timeout
add idle connection timeout and idle-timeout flag
2018-11-16 09:53:02 +01:00
ahh
acce797e55 add logging 2018-11-15 13:56:10 -05:00
ahh
175fc8d68b add timeout and flag 2018-11-15 13:38:18 -05:00
Manfred Touron
227b64aaac do not use pty on windows for compatiblity (#42) 2018-02-28 17:45:30 +01:00
6 changed files with 34 additions and 4 deletions

View File

@@ -414,4 +414,4 @@ This is totally experimental for now, so please file issues to let me know what
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmoul%2Fsshportal.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmoul%2Fsshportal?ref=badge_large) [![GuardRails badge](https://badges.production.guardrails.io/moul/sshportal.svg)](https://www.guardrails.io)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmoul%2Fsshportal.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmoul%2Fsshportal?ref=badge_large)

View File

@@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"time"
"github.com/urfave/cli"
)
@@ -13,6 +14,7 @@ type configServe struct {
logsLocation string
bindAddr string
debug, demo bool
idleTimeout time.Duration
}
func parseServeConfig(c *cli.Context) (*configServe, error) {
@@ -24,6 +26,7 @@ func parseServeConfig(c *cli.Context) (*configServe, error) {
debug: c.Bool("debug"),
demo: c.Bool("demo"),
logsLocation: c.String("logs-location"),
idleTimeout: c.Duration("idle-timeout"),
}
switch len(ret.aesKey) {
case 0, 16, 24, 32:

View File

@@ -1,3 +1,4 @@
// +build !windows
package main
import (

12
hidden_unsupported.go Normal file
View File

@@ -0,0 +1,12 @@
// +build windows
package main
import (
"fmt"
"github.com/urfave/cli"
)
// testServer is an hidden handler used for integration tests
func testServer(c *cli.Context) error { return fmt.Errorf("not supported on this architecture") }

14
main.go
View File

@@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"math"
"math/rand"
"net"
"os"
@@ -79,6 +80,11 @@ func main() {
Value: "./log",
Usage: "Store user session files",
},
cli.DurationFlag{
Name: "idle-timeout",
Value: 0,
Usage: "Duration before an inactive connection is timed out (0 to disable)",
},
},
}, {
Name: "healthcheck",
@@ -144,6 +150,12 @@ func server(c *configServe) (err error) {
Version: fmt.Sprintf("sshportal-%s", Version),
ChannelHandler: channelHandler,
}
if c.idleTimeout != 0 {
srv.IdleTimeout = c.idleTimeout
// gliderlabs/ssh requires MaxTimeout to be non-zero if we want to use IdleTimeout.
// So, set it to the max value, because we don't want a max timeout.
srv.MaxTimeout = math.MaxInt64
}
for _, opt := range []ssh.Option{
// custom PublicKeyAuth handler
@@ -157,6 +169,6 @@ func server(c *configServe) (err error) {
}
}
log.Printf("info: SSH Server accepting connections on %s", c.bindAddr)
log.Printf("info: SSH Server accepting connections on %s, idle-timout=%v", c.bindAddr, c.idleTimeout)
return srv.Serve(ln)
}

View File

@@ -5,6 +5,8 @@ import (
"io"
"log"
"os"
"path/filepath"
"strconv"
"strings"
"time"
@@ -124,8 +126,8 @@ func pipe(lreqs, rreqs <-chan *gossh.Request, lch, rch gossh.Channel, logsLocati
errch := make(chan error, 1)
channeltype := newChan.ChannelType()
file_name := strings.Join([]string{logsLocation, "/", user, "-", channeltype, "-", time.Now().Format(time.RFC3339)}, "") // get user
fileNameUnix := strings.Join([]string{logsLocation, "/", user, "-", channeltype, "-", strconv.FormatInt(time.Now().UnixNano(), 10)}, "") // get user
file_name := filepath.FromSlash(fileNameUnix)
f, err := os.OpenFile(file_name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0640)
defer f.Close()