代码清理
This commit is contained in:
@@ -34,7 +34,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
unrecognizedAddrType = fmt.Errorf("Unrecognized address type")
|
||||
unrecognizedAddrType = fmt.Errorf("unrecognized address type")
|
||||
)
|
||||
|
||||
// AddressRewriter is used to rewrite a destination transparently
|
||||
@@ -156,9 +156,9 @@ func (server *Server) parseTarget(reader io.Reader, writer io.Writer) (*AddrSpec
|
||||
if err != nil {
|
||||
err := sendReply(writer, hostUnreachable, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to send reply: %v", err)
|
||||
return nil, fmt.Errorf("failed to send reply: %v", err)
|
||||
}
|
||||
return nil, fmt.Errorf("Failed to resolve destination '%v': %v", dest.FQDN, err)
|
||||
return nil, fmt.Errorf("failed to resolve destination '%v': %v", dest.FQDN, err)
|
||||
}
|
||||
dest.IP = addr
|
||||
|
||||
@@ -308,16 +308,16 @@ func (server *Server) handleBind(ctx context.Context, conn net.Conn, req *Reques
|
||||
// Check if this is allowed
|
||||
if ctx_, ok := server.config.Rules.Allow(ctx, req); !ok {
|
||||
if err := sendReply(conn, ruleFailure, nil); err != nil {
|
||||
return fmt.Errorf("Failed to send reply: %v", err)
|
||||
return fmt.Errorf("failed to send reply: %v", err)
|
||||
}
|
||||
return fmt.Errorf("Bind to %v blocked by rules", req.DestAddr)
|
||||
return fmt.Errorf("bind to %v blocked by rules", req.DestAddr)
|
||||
} else {
|
||||
ctx = ctx_
|
||||
}
|
||||
|
||||
// TODO: Support bind
|
||||
if err := sendReply(conn, commandNotSupported, nil); err != nil {
|
||||
return fmt.Errorf("Failed to send reply: %v", err)
|
||||
return fmt.Errorf("failed to send reply: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -326,16 +326,16 @@ func (server *Server) handleAssociate(ctx context.Context, conn net.Conn, req *R
|
||||
// Check if this is allowed
|
||||
if ctx_, ok := server.config.Rules.Allow(ctx, req); !ok {
|
||||
if err := sendReply(conn, ruleFailure, nil); err != nil {
|
||||
return fmt.Errorf("Failed to send reply: %v", err)
|
||||
return fmt.Errorf("failed to send reply: %v", err)
|
||||
}
|
||||
return fmt.Errorf("Associate to %v blocked by rules", req.DestAddr)
|
||||
return fmt.Errorf("associate to %v blocked by rules", req.DestAddr)
|
||||
} else {
|
||||
ctx = ctx_
|
||||
}
|
||||
|
||||
// TODO: Support associate
|
||||
if err := sendReply(conn, commandNotSupported, nil); err != nil {
|
||||
return fmt.Errorf("Failed to send reply: %v", err)
|
||||
return fmt.Errorf("failed to send reply: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user