$26 GRAYBYTE WORDPRESS FILE MANAGER $43

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/usr/lib/golang/src/net/

HOME
Current File : /usr/lib/golang/src/net//interface.go
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package net

import (
	"errors"
	"internal/itoa"
	"sync"
	"time"
	_ "unsafe"
)

// BUG(mikio): On JS, methods and functions related to
// Interface are not implemented.

// BUG(mikio): On AIX, DragonFly BSD, NetBSD, OpenBSD, Plan 9 and
// Solaris, the MulticastAddrs method of Interface is not implemented.

// errNoSuchInterface should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
//   - github.com/sagernet/sing
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname errNoSuchInterface

var (
	errInvalidInterface         = errors.New("invalid network interface")
	errInvalidInterfaceIndex    = errors.New("invalid network interface index")
	errInvalidInterfaceName     = errors.New("invalid network interface name")
	errNoSuchInterface          = errors.New("no such network interface")
	errNoSuchMulticastInterface = errors.New("no such multicast network interface")
)

// Interface represents a mapping between network interface name
// and index. It also represents network interface facility
// information.
type Interface struct {
	Index        int          // positive integer that starts at one, zero is never used
	MTU          int          // maximum transmission unit
	Name         string       // e.g., "en0", "lo0", "eth0.100"; may be the empty string
	HardwareAddr HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form
	Flags        Flags        // e.g., FlagUp, FlagLoopback, FlagMulticast
}

type Flags uint

const (
	FlagUp           Flags = 1 << iota // interface is administratively up
	FlagBroadcast                      // interface supports broadcast access capability
	FlagLoopback                       // interface is a loopback interface
	FlagPointToPoint                   // interface belongs to a point-to-point link
	FlagMulticast                      // interface supports multicast access capability
	FlagRunning                        // interface is in running state
)

var flagNames = []string{
	"up",
	"broadcast",
	"loopback",
	"pointtopoint",
	"multicast",
	"running",
}

func (f Flags) String() string {
	s := ""
	for i, name := range flagNames {
		if f&(1<<uint(i)) != 0 {
			if s != "" {
				s += "|"
			}
			s += name
		}
	}
	if s == "" {
		s = "0"
	}
	return s
}

// Addrs returns a list of unicast interface addresses for a specific
// interface.
func (ifi *Interface) Addrs() ([]Addr, error) {
	if ifi == nil {
		return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterface}
	}
	ifat, err := interfaceAddrTable(ifi)
	if err != nil {
		err = &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err}
	}
	return ifat, err
}

// MulticastAddrs returns a list of multicast, joined group addresses
// for a specific interface.
func (ifi *Interface) MulticastAddrs() ([]Addr, error) {
	if ifi == nil {
		return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterface}
	}
	ifat, err := interfaceMulticastAddrTable(ifi)
	if err != nil {
		err = &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err}
	}
	return ifat, err
}

// Interfaces returns a list of the system's network interfaces.
func Interfaces() ([]Interface, error) {
	ift, err := interfaceTable(0)
	if err != nil {
		return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err}
	}
	if len(ift) != 0 {
		zoneCache.update(ift, false)
	}
	return ift, nil
}

// InterfaceAddrs returns a list of the system's unicast interface
// addresses.
//
// The returned list does not identify the associated interface; use
// Interfaces and [Interface.Addrs] for more detail.
func InterfaceAddrs() ([]Addr, error) {
	ifat, err := interfaceAddrTable(nil)
	if err != nil {
		err = &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err}
	}
	return ifat, err
}

// InterfaceByIndex returns the interface specified by index.
//
// On Solaris, it returns one of the logical network interfaces
// sharing the logical data link; for more precision use
// [InterfaceByName].
func InterfaceByIndex(index int) (*Interface, error) {
	if index <= 0 {
		return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterfaceIndex}
	}
	ift, err := interfaceTable(index)
	if err != nil {
		return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err}
	}
	ifi, err := interfaceByIndex(ift, index)
	if err != nil {
		err = &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err}
	}
	return ifi, err
}

func interfaceByIndex(ift []Interface, index int) (*Interface, error) {
	for _, ifi := range ift {
		if index == ifi.Index {
			return &ifi, nil
		}
	}
	return nil, errNoSuchInterface
}

// InterfaceByName returns the interface specified by name.
func InterfaceByName(name string) (*Interface, error) {
	if name == "" {
		return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterfaceName}
	}
	ift, err := interfaceTable(0)
	if err != nil {
		return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err}
	}
	if len(ift) != 0 {
		zoneCache.update(ift, false)
	}
	for _, ifi := range ift {
		if name == ifi.Name {
			return &ifi, nil
		}
	}
	return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errNoSuchInterface}
}

// An ipv6ZoneCache represents a cache holding partial network
// interface information. It is used for reducing the cost of IPv6
// addressing scope zone resolution.
//
// Multiple names sharing the index are managed by first-come
// first-served basis for consistency.
type ipv6ZoneCache struct {
	sync.RWMutex                // guard the following
	lastFetched  time.Time      // last time routing information was fetched
	toIndex      map[string]int // interface name to its index
	toName       map[int]string // interface index to its name
}

var zoneCache = ipv6ZoneCache{
	toIndex: make(map[string]int),
	toName:  make(map[int]string),
}

// update refreshes the network interface information if the cache was last
// updated more than 1 minute ago, or if force is set. It reports whether the
// cache was updated.
func (zc *ipv6ZoneCache) update(ift []Interface, force bool) (updated bool) {
	zc.Lock()
	defer zc.Unlock()
	now := time.Now()
	if !force && zc.lastFetched.After(now.Add(-60*time.Second)) {
		return false
	}
	zc.lastFetched = now
	if len(ift) == 0 {
		var err error
		if ift, err = interfaceTable(0); err != nil {
			return false
		}
	}
	zc.toIndex = make(map[string]int, len(ift))
	zc.toName = make(map[int]string, len(ift))
	for _, ifi := range ift {
		if ifi.Name != "" {
			zc.toIndex[ifi.Name] = ifi.Index
			if _, ok := zc.toName[ifi.Index]; !ok {
				zc.toName[ifi.Index] = ifi.Name
			}
		}
	}
	return true
}

func (zc *ipv6ZoneCache) name(index int) string {
	if index == 0 {
		return ""
	}
	updated := zoneCache.update(nil, false)
	zoneCache.RLock()
	name, ok := zoneCache.toName[index]
	zoneCache.RUnlock()
	if !ok && !updated {
		zoneCache.update(nil, true)
		zoneCache.RLock()
		name, ok = zoneCache.toName[index]
		zoneCache.RUnlock()
	}
	if !ok { // last resort
		name = itoa.Uitoa(uint(index))
	}
	return name
}

func (zc *ipv6ZoneCache) index(name string) int {
	if name == "" {
		return 0
	}
	updated := zoneCache.update(nil, false)
	zoneCache.RLock()
	index, ok := zoneCache.toIndex[name]
	zoneCache.RUnlock()
	if !ok && !updated {
		zoneCache.update(nil, true)
		zoneCache.RLock()
		index, ok = zoneCache.toIndex[name]
		zoneCache.RUnlock()
	}
	if !ok { // last resort
		index, _, _ = dtoi(name)
	}
	return index
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.30 PM
root / root
0755
http
--
16 Dec 2025 9.30 PM
root / root
0755
internal
--
4 Dec 2025 6.06 PM
root / root
0755
mail
--
16 Dec 2025 9.30 PM
root / root
0755
netip
--
16 Dec 2025 9.30 PM
root / root
0755
rpc
--
16 Dec 2025 9.30 PM
root / root
0755
smtp
--
16 Dec 2025 9.30 PM
root / root
0755
textproto
--
16 Dec 2025 9.30 PM
root / root
0755
url
--
16 Dec 2025 9.30 PM
root / root
0755
addrselect.go
9.452 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_aix.go
0.568 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_android.go
0.266 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_bsd.go
0.335 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_darwin.go
0.291 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_linux.go
0.627 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_netbsd.go
0.27 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_openbsd.go
0.27 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_resnew.go
0.566 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_resold.go
0.565 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_socknew.go
0.735 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_sockold.go
0.822 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_solaris.go
0.324 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_stub.go
1.331 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_unix.go
11.618 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_unix_cgo.go
2.424 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_unix_cgo_res.go
0.871 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_unix_cgo_resn.go
0.956 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo_unix_syscall.go
3.061 KB
4 Dec 2025 6.06 PM
root / root
0644
conf.go
15.892 KB
4 Dec 2025 6.06 PM
root / root
0644
dial.go
28.603 KB
4 Dec 2025 6.06 PM
root / root
0644
dnsclient.go
5.672 KB
4 Dec 2025 6.06 PM
root / root
0644
dnsclient_unix.go
24.666 KB
4 Dec 2025 6.06 PM
root / root
0644
dnsconfig.go
2.186 KB
4 Dec 2025 6.06 PM
root / root
0644
dnsconfig_unix.go
4.12 KB
4 Dec 2025 6.06 PM
root / root
0644
dnsconfig_windows.go
1.606 KB
4 Dec 2025 6.06 PM
root / root
0644
error_plan9.go
0.219 KB
4 Dec 2025 6.06 PM
root / root
0644
error_posix.go
0.53 KB
4 Dec 2025 6.06 PM
root / root
0644
error_unix.go
0.373 KB
4 Dec 2025 6.06 PM
root / root
0644
error_windows.go
0.347 KB
4 Dec 2025 6.06 PM
root / root
0644
fd_fake.go
3.874 KB
4 Dec 2025 6.06 PM
root / root
0644
fd_js.go
0.612 KB
4 Dec 2025 6.06 PM
root / root
0644
fd_plan9.go
3.723 KB
4 Dec 2025 6.06 PM
root / root
0644
fd_posix.go
4.557 KB
4 Dec 2025 6.06 PM
root / root
0644
fd_unix.go
5.244 KB
4 Dec 2025 6.06 PM
root / root
0644
fd_wasip1.go
0.484 KB
4 Dec 2025 6.06 PM
root / root
0644
fd_windows.go
7.496 KB
4 Dec 2025 6.06 PM
root / root
0644
file.go
1.674 KB
4 Dec 2025 6.06 PM
root / root
0644
file_plan9.go
2.769 KB
4 Dec 2025 6.06 PM
root / root
0644
file_posix.go
2.227 KB
4 Dec 2025 6.06 PM
root / root
0644
file_stub.go
0.47 KB
4 Dec 2025 6.06 PM
root / root
0644
file_unix.go
0.596 KB
4 Dec 2025 6.06 PM
root / root
0644
file_wasip1.go
2.196 KB
4 Dec 2025 6.06 PM
root / root
0644
file_windows.go
1.14 KB
4 Dec 2025 6.06 PM
root / root
0644
hook.go
0.912 KB
4 Dec 2025 6.06 PM
root / root
0644
hook_plan9.go
0.206 KB
4 Dec 2025 6.06 PM
root / root
0644
hook_unix.go
0.643 KB
4 Dec 2025 6.06 PM
root / root
0644
hook_windows.go
0.703 KB
4 Dec 2025 6.06 PM
root / root
0644
hosts.go
3.476 KB
4 Dec 2025 6.06 PM
root / root
0644
interface.go
7.624 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_aix.go
4.458 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_bsd.go
2.829 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_bsdvar.go
0.599 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_darwin.go
1.144 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_freebsd.go
1.145 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_linux.go
6.661 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_plan9.go
5.033 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_solaris.go
2.134 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_stub.go
0.795 KB
4 Dec 2025 6.06 PM
root / root
0644
interface_windows.go
5.493 KB
4 Dec 2025 6.06 PM
root / root
0644
ip.go
14.789 KB
4 Dec 2025 6.06 PM
root / root
0644
iprawsock.go
7.033 KB
4 Dec 2025 6.06 PM
root / root
0644
iprawsock_plan9.go
0.854 KB
4 Dec 2025 6.06 PM
root / root
0644
iprawsock_posix.go
3.895 KB
4 Dec 2025 6.06 PM
root / root
0644
ipsock.go
9.428 KB
4 Dec 2025 6.06 PM
root / root
0644
ipsock_plan9.go
7.566 KB
4 Dec 2025 6.06 PM
root / root
0644
ipsock_posix.go
8.796 KB
4 Dec 2025 6.06 PM
root / root
0644
lookup.go
29.062 KB
4 Dec 2025 6.06 PM
root / root
0644
lookup_plan9.go
9.768 KB
4 Dec 2025 6.06 PM
root / root
0644
lookup_unix.go
3.327 KB
4 Dec 2025 6.06 PM
root / root
0644
lookup_windows.go
13.514 KB
4 Dec 2025 6.06 PM
root / root
0644
mac.go
1.879 KB
4 Dec 2025 6.06 PM
root / root
0644
mptcpsock_linux.go
4.133 KB
4 Dec 2025 6.06 PM
root / root
0644
mptcpsock_stub.go
0.529 KB
4 Dec 2025 6.06 PM
root / root
0644
net.go
27.689 KB
4 Dec 2025 6.06 PM
root / root
0644
net_fake.go
26.446 KB
4 Dec 2025 6.06 PM
root / root
0644
netcgo_off.go
0.217 KB
4 Dec 2025 6.06 PM
root / root
0644
netcgo_on.go
0.215 KB
4 Dec 2025 6.06 PM
root / root
0644
netgo_netcgo.go
0.442 KB
4 Dec 2025 6.06 PM
root / root
0644
netgo_off.go
0.215 KB
4 Dec 2025 6.06 PM
root / root
0644
netgo_on.go
0.213 KB
4 Dec 2025 6.06 PM
root / root
0644
nss.go
5.482 KB
4 Dec 2025 6.06 PM
root / root
0644
parse.go
5.655 KB
4 Dec 2025 6.06 PM
root / root
0644
pipe.go
5.435 KB
4 Dec 2025 6.06 PM
root / root
0644
port.go
1.458 KB
4 Dec 2025 6.06 PM
root / root
0644
port_unix.go
1.239 KB
4 Dec 2025 6.06 PM
root / root
0644
rawconn.go
2.7 KB
4 Dec 2025 6.06 PM
root / root
0644
rlimit_js.go
0.338 KB
4 Dec 2025 6.06 PM
root / root
0644
rlimit_unix.go
1.101 KB
4 Dec 2025 6.06 PM
root / root
0644
sendfile.go
1.391 KB
4 Dec 2025 6.06 PM
root / root
0644
sendfile_nonwindows.go
0.353 KB
4 Dec 2025 6.06 PM
root / root
0644
sendfile_stub.go
0.409 KB
4 Dec 2025 6.06 PM
root / root
0644
sendfile_windows.go
0.558 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_bsd.go
0.896 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_cloexec.go
0.713 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_cloexec_solaris.go
1.433 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_linux.go
0.97 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_plan9.go
0.256 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_posix.go
6.288 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_stub.go
0.381 KB
4 Dec 2025 6.06 PM
root / root
0644
sock_windows.go
0.783 KB
4 Dec 2025 6.06 PM
root / root
0644
sockaddr_posix.go
1.45 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_aix.go
1.434 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_bsd.go
2.21 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_fake.go
0.933 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_linux.go
1.253 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_plan9.go
0.396 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_posix.go
1.579 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_solaris.go
1.253 KB
4 Dec 2025 6.06 PM
root / root
0644
sockopt_windows.go
1.509 KB
4 Dec 2025 6.06 PM
root / root
0644
sockoptip4_bsdvar.go
0.847 KB
4 Dec 2025 6.06 PM
root / root
0644
sockoptip4_linux.go
1.055 KB
4 Dec 2025 6.06 PM
root / root
0644
sockoptip4_posix_nonlinux.go
1.146 KB
4 Dec 2025 6.06 PM
root / root
0644
sockoptip4_windows.go
0.768 KB
4 Dec 2025 6.06 PM
root / root
0644
sockoptip6_posix.go
1.025 KB
4 Dec 2025 6.06 PM
root / root
0644
sockoptip_stub.go
0.751 KB
4 Dec 2025 6.06 PM
root / root
0644
splice_linux.go
1.715 KB
4 Dec 2025 6.06 PM
root / root
0644
splice_stub.go
0.367 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_cloexec.go
0.939 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsock.go
14.016 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsock_plan9.go
2.299 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsock_posix.go
6.272 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsock_solaris.go
1.318 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsock_unix.go
1.053 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsock_windows.go
1.312 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_darwin.go
1.402 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_openbsd.go
0.741 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_plan9.go
0.744 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_posix.go
0.432 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_solaris.go
3.349 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_stub.go
0.557 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_unix.go
1.324 KB
4 Dec 2025 6.06 PM
root / root
0644
tcpsockopt_windows.go
3.758 KB
4 Dec 2025 6.06 PM
root / root
0644
udpsock.go
11.862 KB
4 Dec 2025 6.06 PM
root / root
0644
udpsock_plan9.go
4.639 KB
4 Dec 2025 6.06 PM
root / root
0644
udpsock_posix.go
7.526 KB
4 Dec 2025 6.06 PM
root / root
0644
unixsock.go
10.252 KB
4 Dec 2025 6.06 PM
root / root
0644
unixsock_plan9.go
1.243 KB
4 Dec 2025 6.06 PM
root / root
0644
unixsock_posix.go
6.642 KB
4 Dec 2025 6.06 PM
root / root
0644
unixsock_readmsg_cloexec.go
0.639 KB
4 Dec 2025 6.06 PM
root / root
0644
unixsock_readmsg_cmsg_cloexec.go
0.324 KB
4 Dec 2025 6.06 PM
root / root
0644
unixsock_readmsg_other.go
0.269 KB
4 Dec 2025 6.06 PM
root / root
0644
writev_unix.go
0.65 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF