github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/http/dial_others.go (about)

     1  //go:build !linux
     2  // +build !linux
     3  
     4  // Copyright (c) 2015-2021 MinIO, Inc.
     5  //
     6  // This file is part of MinIO Object Storage stack
     7  //
     8  // This program is free software: you can redistribute it and/or modify
     9  // it under the terms of the GNU Affero General Public License as published by
    10  // the Free Software Foundation, either version 3 of the License, or
    11  // (at your option) any later version.
    12  //
    13  // This program is distributed in the hope that it will be useful
    14  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  // GNU Affero General Public License for more details.
    17  //
    18  // You should have received a copy of the GNU Affero General Public License
    19  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    20  
    21  package http
    22  
    23  import (
    24  	"context"
    25  	"net"
    26  	"syscall"
    27  	"time"
    28  )
    29  
    30  // TODO: if possible implement for non-linux platforms, not a priority at the moment
    31  //
    32  //nolint:unused
    33  func setTCPParametersFn(opts TCPOptions) func(network, address string, c syscall.RawConn) error {
    34  	return func(network, address string, c syscall.RawConn) error {
    35  		return nil
    36  	}
    37  }
    38  
    39  // DialContext is a function to make custom Dial for internode communications
    40  type DialContext func(ctx context.Context, network, address string) (net.Conn, error)
    41  
    42  // NewInternodeDialContext setups a custom dialer for internode communication
    43  var NewInternodeDialContext = NewCustomDialContext
    44  
    45  // NewCustomDialContext configures a custom dialer for internode communications
    46  func NewCustomDialContext(dialTimeout time.Duration, _ TCPOptions) DialContext {
    47  	return func(ctx context.Context, network, addr string) (net.Conn, error) {
    48  		dialer := &net.Dialer{
    49  			Timeout: dialTimeout,
    50  		}
    51  		return dialer.DialContext(ctx, network, addr)
    52  	}
    53  }