Browse Source

A tiny bit of code clean-up.

master
J. David Lee 5 years ago
parent
commit
43af1627d1
1 changed files with 5 additions and 7 deletions
  1. +5
    -7
      server.go

+ 5
- 7
server.go View File

@ -61,22 +61,20 @@ func RunServer(path string) {
func serverHandler(conn net.Conn, conf ServerConfig) {
defer conn.Close()
var err error
var cConn net.Conn // Client connection.
buf := make([]byte, len(conf.Password))
if _, err = conn.Read(buf); err != nil {
// Read password.
buf := make([]byte, len(conf.password))
if _, err := conn.Read(buf); err != nil {
log.Printf("Failed to read password: %v", err)
return
}
if subtle.ConstantTimeCompare(buf, conf.password) != 1 {
log.Printf("Invalid password provided")
log.Printf("Invalid password")
return
}
// Connect to the remote address for the client.
cConn, err = net.Dial("tcp", conf.Forward)
cConn, err := net.Dial("tcp", conf.Forward)
if err != nil {
log.Printf("Failed to connect to host %s: %v", conf.Forward, err)
return


Loading…
Cancel
Save