mirror of
https://github.com/mmatczuk/go-http-tunnel.git
synced 2026-05-15 14:16:17 -06:00
23 lines
394 B
Go
23 lines
394 B
Go
// Copyright (C) 2017 Michał Matczuk
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package tunnel
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
)
|
|
|
|
func keepAlive(conn net.Conn) error {
|
|
c, ok := conn.(*net.TCPConn)
|
|
if !ok {
|
|
return fmt.Errorf("Bad connection type: %T", c)
|
|
}
|
|
|
|
if err := c.SetKeepAlive(true); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|