Better error management

This commit is contained in:
Quentin 2021-11-20 15:10:21 +01:00
parent e10f04c5e3
commit a171e84189
3 changed files with 9 additions and 2 deletions

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
s3_cache
.git
bagage

View file

@ -2,7 +2,8 @@ FROM golang:1.17.0-alpine3.14 as builder
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates
WORKDIR /opt WORKDIR /opt
COPY *.go go.mod go.sum /opt/ COPY . /opt/
RUN ls /opt/
RUN go build . RUN go build .
FROM scratch FROM scratch

View file

@ -97,6 +97,7 @@ func handleSSHConn(nConn net.Conn, dconfig *Config, config *ssh.ServerConfig) {
serverConn, chans, reqs, err := ssh.NewServerConn(nConn, config) serverConn, chans, reqs, err := ssh.NewServerConn(nConn, config)
if err != nil { if err != nil {
log.Printf("failed to handshake: ", err) log.Printf("failed to handshake: ", err)
return
} }
defer serverConn.Conn.Close() defer serverConn.Conn.Close()
user := serverConn.Conn.User() user := serverConn.Conn.User()
@ -120,6 +121,7 @@ func handleSSHConn(nConn net.Conn, dconfig *Config, config *ssh.ServerConfig) {
channel, requests, err := newChannel.Accept() channel, requests, err := newChannel.Accept()
if err != nil { if err != nil {
log.Print("could not accept channel.", err) log.Print("could not accept channel.", err)
return
} }
log.Printf("Channel accepted\n") log.Printf("Channel accepted\n")
@ -155,7 +157,8 @@ func handleSSHConn(nConn net.Conn, dconfig *Config, config *ssh.ServerConfig) {
server, err := sftp.NewServer(ctx, channel, &fs) server, err := sftp.NewServer(ctx, channel, &fs)
if err != nil { if err != nil {
log.Fatal(err) log.Println(err)
return
} }
if err := server.Serve(); err == io.EOF { if err := server.Serve(); err == io.EOF {