github.com/metacubex/mihomo@v1.18.5/common/net/addr.go (about)

     1  package net
     2  
     3  import (
     4  	"net"
     5  )
     6  
     7  type CustomAddr interface {
     8  	net.Addr
     9  	RawAddr() net.Addr
    10  }
    11  
    12  type customAddr struct {
    13  	networkStr string
    14  	addrStr    string
    15  	rawAddr    net.Addr
    16  }
    17  
    18  func (a customAddr) Network() string {
    19  	return a.networkStr
    20  }
    21  
    22  func (a customAddr) String() string {
    23  	return a.addrStr
    24  }
    25  
    26  func (a customAddr) RawAddr() net.Addr {
    27  	return a.rawAddr
    28  }
    29  
    30  func NewCustomAddr(networkStr string, addrStr string, rawAddr net.Addr) CustomAddr {
    31  	return customAddr{
    32  		networkStr: networkStr,
    33  		addrStr:    addrStr,
    34  		rawAddr:    rawAddr,
    35  	}
    36  }