Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
id
auth
Commits
c7e337c9
Commit
c7e337c9
authored
Dec 15, 2017
by
ale
Browse files
Improve error handling in UNIX socket server
Log errors, and drop unnecessary replies when shutting down a connection.
parent
f4a6a804
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/unixserver.go
View file @
c7e337c9
...
...
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"errors"
"fmt"
"io"
"log"
"net"
...
...
@@ -159,11 +160,11 @@ func (s *SocketServer) handle(nc net.Conn) {
return
case
nargs
==
2
&&
cmd
==
"auth"
:
if
err
:=
s
.
handleAuth
(
c
,
parts
[
1
]);
err
!=
nil
{
log
.
Printf
(
"error
from %s: %v"
,
nc
.
RemoteAddr
()
,
err
)
log
.
Printf
(
"error
in auth: %v"
,
err
)
return
}
default
:
c
.
Printf
Line
(
"syntax error
from %s"
,
nc
.
RemoteAddr
()
)
log
.
Printf
(
"syntax error
"
)
return
}
}
...
...
@@ -172,8 +173,7 @@ func (s *SocketServer) handle(nc net.Conn) {
func
(
s
*
SocketServer
)
handleAuth
(
c
*
textproto
.
Conn
,
line
[]
byte
)
error
{
var
req
auth
.
Request
if
err
:=
s
.
codec
.
Decode
(
line
,
&
req
);
err
!=
nil
{
c
.
PrintfLine
(
"syntax error"
)
return
errors
.
New
(
"syntax error"
)
return
fmt
.
Errorf
(
"decoding error: %v"
,
err
)
}
// Set a timeout for the request.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment